The status line will change to Tab Size: 4 and you'll see the indent in the file visibly jump out to your new setting. Use Tab Width: 4 to change the size of the tabs. The status line will change to Tab Size: 2 to show you that it's using tabs, and if you select text in the buffer you can see that the leading white space is now tab characters. Use Convert Indentation to Tabs to convert all of the leading indent from spaces to tabs. The status line will change to Spaces: 2 and you'll see the number of indent guides double as the new setting takes effect. Use Guess Settings From Buffer or Tab Width: 2 to change the tab size to the one uses in the file. The easiest place to find those commands is in the menu that pops up when you click the status bar where it's showing you your indent settings ( Spaces: 4), but make sure that you're actively editing the appropriate file first because every open file is allowed to have different settings: If that's not desirable, you can perform the change manually with a few steps, using commands Sublime already has built in. So based on the type of file that you're editing and the contents of that file, it's possible that the contents may be changed in ways other than just changing the indent. Results of this may or may not be mixed it uses the same internal logic that Sublime uses for indenting while you're typing. Perhaps the simplest way to do that would be to select the entire file with Selection > Select All (or the appropriate key), and then select Edit > Line > Reindent from the menu or Indentation: Reindent Lines from the command palette. In any case, you have to take steps to manually fix the file so that it matches your preferred indentation settings. If you had detect_indentation turned on, the file would visually appear the same, but Sublime would change the tab_size to 2 for that file to match what it sees in the buffer. Since we know that the indent is definitely set to 4 but the code looks like it's indented only 2, we know that your code doesn't contain any tab characters, or it would appear the way you want it to. Looking at the image in your question, you can see that the status line says Spaces: 4 to indicate that the settings are tab_size of 4 and translate_tabs_to_spaces being true, and the indent guides are positioned the way you want, but the code is indented wrong. ![]() When it's set to true (the default, but not what you're using) when a file is loaded Sublime tries to guess the appropriate indent settings by analyzing the file. This is visualized in menus as an item named Indent Using Spaces being either checked or unchecked as appropriate.ĭetect_indentation controls whether or not Sublime honours the above two settings to the letter or not. Translate_tabs_to_spaces tells Sublime that any time it would insert a literal tab character, it should instead convert that tab into tab_size spaces on the fly. Tab_size controls how wide a tab character is assumed to be, in characters, which is used in a visual setting to determine not only how much space a tab should take up, but also things like the positioning of the indent guides. The three settings that control this are the ones that you mentioned in your question: The issue you're facing here is that you have set your preferred indent size in Sublime, but the file that you're working with is already indented in a way that doesn't match your settings.Īs such you should be able to notice that when you press Tab it skips four spaces like it should, and newly added code is indented the way you want it to be but existing code is left alone unless you manually fix it. "trim_trailing_white_space_on_save": true, "color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme", LoadMore: '#js-loadMore-lightbox-gallery', Type }} " style="padding: 0px !important margin: 0px Back While designing, I always balance usability and standard elements with other design criteria. I've been looking for the reason why my code kept showing 2 spaces instead of 4.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |