Search code examples
javascripthtmlsublimetext3sublimetextcode-formatting

Reindenting all files inside a folder in Sublime


I have Sublime Text 3 and what i want to do is reindent all the files inside a folder I am presently using HTML-CSS-JS Prettify as my plugin to reindent. So I want to right-click on the folder icon which is on the sidebar and get an option of reindenting all the files inside them.

Thanks


Solution

  • You can get pretty close if you're willing to write your own plugin.

    The plugin code:

    import sublime
    import sublime_plugin
    
    class ReindentAllCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            [v.run_command('htmlprettify') for v in sublime.active_window().views()]
    

    This is based on this response on the Sublime Text forums. It runs the htmlprettify command in every open file. You could replace that with a different plugin, if you want.

    To open all files in a folder, you can follow the instructions here.