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.

I've noticed that dragging your mouse to highlight, say, 5 lines in a row and then pressing the TAB button does not do it for you... Is there a way to TAB in bulk, or is just something that is usually done manually?

Also, is there a way to likewise un-TAB (by this I don't mean get rid of *all* tabs) those 5 adjacent lines? So let's say line 1 is tabbed twice, line 2 is tabbed four times, etc, can it be so that if you want to un-TAB them together, line 1 will now be tabbed only once, and line 2 now tabbed 3 times, etc?

share|improve this question
1  
BTW, if you find you use the mouse a lot when working with VIM, you really aren't tapping into VIM's full power. I suggest spending some time looking at :help navigation until most of those commands are second nature and you're keeping your hands on the keyboard! –  Codie CodeMonkey Dec 21 '11 at 16:53
add comment

3 Answers

up vote 9 down vote accepted

Shift-V to enter Visual Line mode. Select the lines that you want. Press >.

To untab, do the same to select, but use <.

share|improve this answer
2  
And of course you can use count, so 5<< would unindent 5 lines at a time. –  Wayne Werner Dec 20 '11 at 19:50
    
I thought about that as my first answer and that is the best solution if you know exactly how many lines you want to effect...I'm just too lazy to count lines most of the time :) –  EBGreen Dec 20 '11 at 19:54
1  
I tend to use >} a lot to indent paragraphs (in source code). I also use >'b after marking the endpoint with mb –  RedGrittyBrick Dec 20 '11 at 20:41
add comment

Using the command line:

  1. : to enter command
  2. . to select current line
  3. ,[+,-] use + or - to select forward or back
  4. [number] the number of lines
  5. > or < to indent or outdent

or

  1. : to enter command mode
  2. [num],[num] to select a range of lines by line number
  3. > or < to indent or outdent

For example:

:.,+5>

:.,-3<

:12,25>
share|improve this answer
1  
+1'ed for the command mode tip. –  stefgosselin Dec 20 '11 at 20:05
add comment

Some ways to do it.

  • Enter viusal mode v and press > for adding tabs and < for removing tabs
  • Press 5>> to add tabs to five lines or 5<< to remove
  • Put a mark on the fifth line ma go to the first line and do >'a

Of course in many situations you can replace >/< with = to do auto-indent

share|improve this answer
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.