Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sublime text 2 change indent template

I would like change the basic indentation on template ruby haml. He is set when I create a new file to 'Tab Size: 4' How change it in 'Spaces: 2'?

Thanks.

like image 639
Guillaume Avatar asked Feb 16 '12 11:02

Guillaume


People also ask

How do you fix inconsistent tabs and spaces in indentation in sublime?

If you are using a text editor such as Sublime Text, use the option Convert indentation to spaces to make your code free from the “TabError: inconsistent use of tabs and spaces in indentation” error.

How do I change tabs in Sublime Text?

Use Cmd (Mac) or Alt (Windows) with the number keys 0–9 to switch between tabs in Sublime Text. For example hit Cmd–2 (Mac) or Alt–2 (Windows) to switch to the second tab. You can also use Ctrl–Tab (Mac and Windows) to cycle through your tabs.

How do I change sublime settings?

Changing Preferences. Open the Sublime Text default settings file: Mac OS X: Sublime Text 2 > Preferences > Settings - Default. Windows: Preferences > Settings - Default. Linux: Preferences > Settings - Default.


2 Answers

To change the indentation settings just for ruby files create a new file named Ruby.sublime-settings, based on your OS, in %APPDATA%\Sublime Text 2\Packages\User or ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/ or ~/.config/sublime-text-2/Packages/User/' with the following content:

{
  // The number of spaces a tab is considered equal to
  "tab_size": 2,

  // Set to true to insert spaces when tab is pressed
  "translate_tabs_to_spaces": true
}
like image 57
dsander Avatar answered Oct 04 '22 02:10

dsander


There is a better and easier way to set the indentation. To change indentation for all file types go to:

Preferences -> Settings - Default/User

To change indentation for a specific file type, open a file type of your choice in the editor, and then go to:

Preferences -> Settings -> More -> Syntax Specific -> User

In both cases Sublime Text will open a file called Ruby.sublime-settings. Save the following settings:

{
  "tab_size": 2,
  "translate_tabs_to_spaces": true
}

You can read more about this in this SO question.

like image 26
Mohamad Avatar answered Oct 04 '22 02:10

Mohamad