Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
Or try gq for autoformatting. –  frabjous Aug 6 '11 at 14:21
add comment

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.

share|improve this answer
    
Replacing >/<with = is often when you format your code. –  tidbeck Aug 6 '11 at 15:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.