If I want to indent all lines in a document, I can type >G
to apply it to the current line and below, followed by and >gg
to apply it to the lines above.
Is there a combination I can use to just apply >
to all lines at once?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou are looking for the :>
command and a range of 1,$
(%
for short) for the whole file.
:%>
For more help see:
:h :>
:h :range
>
, while this answer uses the Command-mode command :>
. These are not, strictly speaking, the same thing. That they have the same name should be considered a coincidence; don't assume you can interchange operators and commands in general. For example, the gU
operator converts text to uppercase, but :%gU
is not a valid command to apply the same to the entire buffer.
Without leaving normal mode you can simply do:
gg>G
Another option that has not been mentioned yet:
:g/^/>
This will run the command >
on all lines that match the pattern ^
.
Downside is that this will overwrite your search history.