问题
When I highlight a block of code in Sublime Text 3 and press the Tab key, it doesn't indent the whole block like it used to. Instead, it deletes the highlighted code.
Anybody know how to fix this?
回答1:
This is a simple alt-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 fix the problem.
回答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.
回答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": "." }
]
},
回答4:
Similar to the answer by Dom above, it also happens when the upgrade message for sublime appears and is not in focus. I've also found that if you open Sublime enable another monitor then the upgrade message appears off screen too.
The only fix seems to be restarting sublime. This also re-centers the dialog box.
回答5:
This was happening to me too, and it was due to the fact that my selected text appeared to be a block, but was actually a single line of wrapped text. By default ST3 will replace a single selected line with a tab
character.
For me, it's more convenient to un/indent selections, whether they are multiple lines or not, so I added the following to my User-specific sublime-keymap file.
{ "keys": ["tab"], "command": "indent", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
]
}
回答6:
I figured out the issue when I click "tab" and check status bar in the bottom which should tell you why it happens.
After I found the related package, I just
- Removed Emmet Style Refloctor package which causes the issue (not Sublime Text itself)
- Restarted the Sublime Text
It works well now.
回答7:
same thing happened to me. Just go to preferences->key bindings then in the user (right) keybindings add this:
[
{ "keys": ["tab"], "command": "indent" },
{ "keys": ["shift+tab"], "command": "unindent" },
]
Then restart sublime and it should work fine!
Note: this does break the tab completing things but copying the tab defaults will fix this. Also if you use enter it works fine as well. Good luck!
来源:https://stackoverflow.com/questions/22383608/sublime-text-3-deleting-code-when-i-hit-tab-key