Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indentation issue using sublime text 2

I have the following problem.

I use ubuntu 12.04 and sublime-text-2 or gedit.

Sometimes i copy/paste something in a haml/ruby file, i indent it at 2 spaces, but when i push it up to github, the indentation is all wrong and not only the part I've copy/pasted. In my editor looks good.

If I open the file with LibreOffice/LeafPad the identation is like on github, but i wanna have it working on ST2.

Any suggestions?

like image 501
vladCovaliov Avatar asked Aug 02 '12 10:08

vladCovaliov


People also ask

How to indent code in Sublime Text?

Sublime Text editor provides various options for code indentation as shown in the following screenshot − Indent option helps to create indentation of the specified code. You have to select the code specified and select the Indent option. You can also use the shortcut Ctrl+ [ after selecting the required code that is to be indented.

Where do I put my settings in Sublime Text?

In general, you should place your settings in Packages/User/Preferences.sublime-settings. If you want to specify settings for a certain file type, for example, Python, you should place them in Packages/User/Python.sublime-settings.

How to indent in Visual Studio Code?

Indent Option Indent option helps to create indentation of the specified code. You have to select the code specified and select the Indent option. You can also use the shortcut Ctrl+ [ after selecting the required code that is to be indented.

What is auto indentation?

Automatic indentation guesses the amount of leading whitespace to insert on each line when you press enter. It's controlled with these settings: Makes auto indent a little smarter, e.g., by indenting the next line after an if statement in C.


1 Answers

To have correct indent across the service you should not use hard tabs

http://opensourcehacker.com/2012/05/13/never-use-hard-tabs/

You can achieve this functionality in Sublime Text 2 with a tab policy setting:

http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings

Also not that you might need to choose new policy for existing files from View > Indentation menu.

You can also mass-convert existing files away from tabs.

With Sublime Text 2:

http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Converting_existing_files_to_use_spaces_instead_of_tabs

... or batch convert the whole project:

http://miohtama.github.com/vvv/tools/expandtabs.html

like image 166
Mikko Ohtamaa Avatar answered Oct 13 '22 23:10

Mikko Ohtamaa