2

How can I add and remove tabs in normal mode in vim? Also, how can I add and remove tabs in visual mode (like selecting a code block in a regular editor and hitting tab or shift tab?

3

in visual mode: select some text, usually a line with V and then hit Shift > or Shift < (to untab)

edit: if it's a line you want to indent then you don't have to select a line, just put the cursor on any line and hit the above shortcuts.

1
  • Or try gq for autoformatting. – frabjous Aug 6 '11 at 14:21
2

That would be the < and > commands.

Examples:

>>

Shift the current line one tab to the right

10<<

Shift the next ten lines one to the left

>'a

Shift the lines from the cursor to the mark a one to the right

>j

Shift the current line, and the one below it, one to the right.

Which is, of course, the generic >{range}, so very flexible.

1
  • Replacing >/<with = is often when you format your code. – tidbeck Aug 6 '11 at 15:43

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.