Sublime Forum

Can I easily change all existing 2-space indents to 4-space indents?

#1

Hi all. In my preferences I have the size of my tab indent set to be equal to 4 spaces. One of my files has several existing lines of code, and those lines are already formatted with tab indents. But for some reason, the size of those tab indents is only two spaces. Is there an easy way to change all existing tab indents in a file from 2 spaces to 4 spaces?

To be clear, when I open this particular file, the size of the tab indent is still 4 spaces. In other words, if I press the tab button, it indents 4 spaces. I’m not sure how all the existing tab indents became 2 spaces instead of 4.

Thanks in advance.

0 Likes

#2

yes, you can:

in the right lower corner, set:

  1. select “Tab width” to currently used tab width
  2. “Convert indentation to tabs”
  3. select “Tab width” to desired tab width
  4. “Convert indentation to spaces” (optional)
2 Likes

#3

First, make sure they’re actually tabs. Also, make sure a plugin didn’t change the configuration… But, the most likely solution is that there are syntax related settings or project / workspace related settings stored which were ignored when the file was opened…

I’ve seen this issue a lot where tab indentation setting will change to what the file has even if I prefer something else. I have had Lua get loaded for *.lua files even though I use GMod Lua for *.lua files and have set it over and over for it ( It bothered me so much I added a feature into my plugin so if a syntax is desired, it’ll be forced )…

There are a few issues with Sublime Text settings system - if a new settings file is created with new keys then those keys won’t get loaded even if you load the file into memory until the editor is restarted… for instance if you install a new plugin, that plugin won’t work until the text editor is restarted unless it doesn’t use the settings object system or uses its own…

I am going to make my own because of the issues with Sublime Text not having proper inheritance, not loading the first load, having issues storing and loading data in some situations, and more…

These are incredibly annoying problems.

0 Likes

#4

@theUltimateSource OK thanks for that–it seems to do what I need.

@Acecool thanks for that as well.

0 Likes

#5

@theUltimateSource I signed up for an account with this forum just to say: Thank you!!! Been looking for an easy way to do this forever, and your trick worked perfectly.

0 Likes