Sublime Text 3 Deleting Code when I hit Tab Key

Solution 1:

This is a simple Alt+tab (Cmd+tab) issue

I have found that this happens when I've missed the "purchase this software" dialogue and have not dismissed it.

Alt-tab (or Cmd-tab on Mac) to check if there is a dialog waiting for a response and dismiss it. This will resolve the issue.

As others have mentioned restarting Sublime will also resolve this issue because it is essentially dismissing the dialogue.

Solution 2:

For anyone else who comes here from google, read this first:

SublimeText 2 (works for 3 as well) suddenly started doing this to me today without changing any settings. All I had to do was restart the program and it fixed itself.

Solution 3:

This is the default behavior for Sublime Text. If you select multiple lines it will indent but if you select single line (selection does not contain a \n), it will run insert_best_completion command and delete the selection.

The fix:

In your user .sublime-keymap add the following:

{ "keys": ["tab"], "command": "indent", "context":
    [
        { "key": "text", "operator": "regex_contains", "operand": "." }
    ]
},

This will make your tab key always indent. Not sure if it will conflict with auto-completion if you have it set up on Tab key.

Same goes for unindenting with shift+tab:

{ "keys": ["shift+tab"], "command": "unindent", "context":
    [
        { "key": "text", "operator": "regex_contains", "operand": "." }
    ]
},