Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I indent a single line multiple times in vi or vim?

I've found several answers on how to indent multiple lines in vim, I want to know how to take a single line and indent it more than once. In effect, I want a shorter version of the following command: ">>>>>>>>>>" (That is 10 right bracket "greater-than" signs.)

like image 447
Cory Klein Avatar asked Sep 13 '10 16:09

Cory Klein


People also ask

How do I indent multiple lines in vi?

press v for visual mode. use up / down arrow to highlight text. press = to indent all the lines you highlighted.

How do I indent a block of text in Vim?

To indent the current line, or a visual block: ctrl-t, ctrl-d - indent current line forward, backwards (insert mode) visual > or < - indent block by sw (repeat with . )


2 Answers

Select what you want (typically with v or Shift+v) then type 5>.

If you need to fix or repeat the same selection, use gv.

like image 93
ldog Avatar answered Sep 24 '22 03:09

ldog


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

like image 42
meagar Avatar answered Sep 23 '22 03:09

meagar