2

I am using vim on Ubuntu 10.10.

In order to indent code, I enter >. But I have to do it twice.

Other command, like < and = are the same. I have to do it twice.

Is it normal? Of I should change something?

How can I fix this?

4 Answers 4

3

That is the normal operation. The first > starts the indent command. The second > commits the indent command. What you put in between defines what you want to indent (defaults to 1 line):

  • >> is indent one line.
  • >5> is indent 5 lines
  • >G is indent to the end of the file.

The >G doesn't need a trailing > to commit the command as the G command is a terminating command already.

6

If you want to indent a line say 3 levels, you can use the "." motion to repeat the last action after indenting.

Eg:

>>..
1
  • Thanks. This worked better for me that the answer marked as accepted from Majenko.
    – Aaron
    Aug 2, 2021 at 21:18
1

If you want to abbreviate this, you can create a macro that indents just the current line or some other preset value. For example:map <tab> >1>

1

I use>} to indent a paragraph (a chunk of code up to the next empty line)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .