Sublime Text 3, convert spaces to tabs

前端 未结 11 2251
[愿得一人]
[愿得一人] 2020-12-07 08:07

I know there are a lot of posts about this, but I couldn´t get it to work.
I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on S

11条回答
  •  有刺的猬
    2020-12-07 08:46

    To automatically convert spaces to tabs on save, add the following Python script to a newly created subfolder called "UnexpandTabsOnSave" within "$SUBLIME_HOME$\Packages\":

    import sublime, sublime_plugin, os
    
    class ConvertSpacesToTabsOnSave( sublime_plugin.EventListener ):
      # Run Sublime's 'unexpand_tabs' command when saving any file
      def on_pre_save( self, view ):
        view.window().run_command( 'unexpand_tabs' )
    

    Thank you for the initial resource.

提交回复
热议问题