Repeat a line command?
I'm new to the more advanced aspects of vi/vim/viemu
I commonly need to select a bit of t开发者_StackOverflow中文版ext and indent/undent, among other things. Right now I have two ways to do this:
- select the text and use
<<
- use a multi-line command such as
:198,205<<
Now, sometimes I need to do this multiple times. When using the dot command though(.
) it will never repeat my last command unless I was previously in insert mode. Instead, it will just delete the current line.
Is there a quick and easy way of doing this?
Use V
to visually select the lines and then press the keys 5
then >
to indent the lines 5 tabs to the right (or just <
to indent once to the left).
If you want to auto-indent the entire file use gg=G
. gg
move to the beginning of the file, =
auto-indent function, G
to the end of the file. This will indent code based on block nesting levels.
For what it's worth, >G
will indent all the lines one tab to the right from the cursor position to the end of file.
You can also auto-indent text marked with the m
bookmark function, i.e. position cursor at start, ma
, position the cursor at end, ='a
精彩评论