MrCarrot
MrCarrot

Reputation: 2778

How do I prevent Sublime Text 3 from auto-indenting a line as a one off

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.

Upvotes: 2

Views: 749

Answers (2)

MrCarrot
MrCarrot

Reputation: 2778

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

Upvotes: 1

sergioFC
sergioFC

Reputation: 6016

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:

  1. Press [Enter] to move to a new line.
  2. Press [shift+home] to select until the beginning of line (spaces or tabs used to indent).
  3. Press [backspace] to remove the selected indentation charaters
  4. You're done. Stop recording and save the macro, then use a custom keybinding to do it in a single step.

Upvotes: 1

Related Questions