Reputation: 392
How do you indent a specific selection of lines in vim, for example line 1, 5 and 6.
Also is their a way to indent lines begining with a certain keyword. For example search for all words begining with def and indent it.
Thanks
Upvotes: 1
Views: 133
Reputation: 172520
To indent line 1, 5 and 6, you can concatenate multiple :>>
commands in a single command-line:
:1>>|5,6>>
The :global
command allows to indent (the same applies to all other Ex commands, too) only lines matching a pattern.
:g/def/>>
Upvotes: 1
Reputation: 17258
To indent line 7
:7 >>
To indent the range of lines 3-5 (indents lines 3,4 and 5)
:3,5 >>
Search for def and indent all matches use the global command g:
:g /def/ >>
Upvotes: 1