How can I postpone one line several times in vi or vim?

I found several answers on how to indent multiple lines in vim, I want to know how to take one line and indent it more than once. Essentially, I want a shorter version of the following command: "→ → → → →" (These are 10 right brackets "more than".)

+44
vim indentation vi text-indent
Sep 13 '10 at 16:50
source share
5 answers

Select what you want (usually with v or Shift + v ), then enter 5> .

If you need to correct or repeat the same choice, use gv .

+67
Sep 13 '10 at 16:52
source share

You can select the current line by pressing v , and then enter 5> to indent the current line 5 times, which is equivalent to pressing > 10 times.

+11
Sep 13 '10 at 16:55
source share

One of the answers “How to quickly separate multiple lines in vi” showed me a neat trick to reassign > in visual mode to re-select visual mode, in .vimrc ...

 vnoremap < <gv vnoremap > >gv 

Then I just select the line (or lines) you want to indent, and click the appropriate direction as many times as you want.

+9
Sep 13 '10 at 17:16
source share

Indent after use. to redo the previous command or u to undo it.

+8
Sep 13 '10 at 17:03
source share

From vim help :help >

To move the line a few "shiftwidth", use Visual Mode or the commands :.

For example:

  Vjj4> move three lines 4 indents to the right :<<< move current line 3 indents to the left :>> 5 move 5 lines 2 indents to the right :5>> move line 5 2 indents to the right 

Or simply, >> and reissue the command with . normally.

0
Aug 31 '17 at 19:33
source share



All Articles