13

I am trying to insert a tab into a document in Sublime Text. I am using tabs for indentation. Usually, I can insert a tab by pressing → Tab. However, sometimes instead of inserting a tab character, this performs a word completion.

It's hard to predict when this will happen, but when I notice it, I then press Backspace                → Tab Backspace

Is there a better way?

0
11

Do you find the word completion feature helpful? If not then turn it off and I'm sure that will fix your problem.

Alternatively if you press shift+tab then that will insert a literal tab.

Or you can disable tab completion by adding this line to Preferences/File Settings - User:

"tab_completion": false

Source

1
  • 7
    Pressing Shift + Tab doesn't work for me.
    – Rockallite
    Nov 25 '16 at 1:02
11

Pressing Shift + Tab doesn't insert a literal tab for me in Sublime Text 3.

The only way for me to insert a literal tab is doing the following things:

  • First, I disable the Indent Using Spaces option via menu ViewIndentation.
  • Then, press Tab to insert a literal tab.

After you're done, switch back the option.

You can also click on the cell of the status bar which says Spaces: n or Tab Size: n, and switch the Indent Using Spaces option there.

1
  • 2
    Another trick I read about in the Sublime Text forum is to insert a character that you know isn't used anywhere in your code (the example given was a backtick, but you could paste a unicode character or something). Then invoke Search/Replace, ensure Regex is enabled, find your character and replace it with \t, which will result in a tab. It isn't super convenient for a one-off (though, neither is toggling the menu option) but works well if you know you're going to be inserting several tab characters.
    – Wilson F
    May 25 '17 at 18:40
1

If you want to use a tab in search/replace, just type a tab on a new line ("Indent using spaces" disabled), select and cut and then paste into either search or replace field.

Thought I'd add this in case anyone found this question like me searching for this option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.