Alex Rivera | Logout

Indent multiple lines quickly in vi

Asked 2008-10-25T03:27:28.013
2469

It should be trivial, and it might even be in the help, but I can't figure out how to navigate it. How do I indent multiple lines quickly in vi?

Edit
Report

1 Answer

87

Key presses for more visual people:

  1. Enter Command Mode:
    Escape

  2. Move around to the start of the area to indent:
    hjkl↑↓←→

  3. Start a block:
    v

  4. Move around to the end of the area to indent:
    hjkl↑↓←→

  5. (Optional) Type the number of indentation levels you want
    0..9

  6. Execute the indentation on the block:
    >

answered 2008-10-25T09:16:00.620

Your Answer