问题
When I'm editing HTML or CSS in Sublime Text 3 the lines auto-indent when I hit the [ENTER] key, which generally is very useful.
On occasion I find myself wanting to paste a line of markup which is already indented, and this results in double indentation.
Is there some other key combination along with the [ENTER] key that prevents the next line from auto-indenting and instead returns the curson to the very beginning of the line? Please note I don't want to turn off auto-indent on a global basis.
回答1:
You can do it in various steps, using various keybindings, so you can simply record a macro and do it in one simple custom keybinding (tools > record macro).
Steps:
- Press [Enter] to move to a new line.
- Press [shift+home] to select until the beginning of line (spaces or tabs used to indent).
- Press [backspace] to remove the selected indentation charaters
- You're done. Stop recording and save the macro, then use a custom keybinding to do it in a single step.
回答2:
I found in Windows that CTRL + SHIFT + V (rather than just CTRL + V) does a "paste and indent" whereby the indentation is corrected as necessary.
It's also possible to switch the default paste for paste as indent as per these instructions: https://gist.github.com/twosixcode/1988097
来源:https://stackoverflow.com/questions/28896916/how-do-i-prevent-sublime-text-3-from-auto-indenting-a-line-as-a-one-off