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?


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.

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

That would be the < and > commands.



Shift the current line one tab to the right


Shift the next ten lines one to the left


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


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

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

  • 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.