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.
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.
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.
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.
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
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With