开发者

Inserting above/below X lines in Vim

I'm wondering ho to insert arbitrary number of lines below curent line wit "o" command. When i type for example 5o, first new line is inserted directly below, so i can write and when I hit esc then the line gets copied four times. Is there any way to directly insert 5 blank lines and after 开发者_开发百科that start typing without the need of 5+o+esc?


My preferred way of doing things like this is to use the dot command.

o<esc> to create the initial blank line, then repeat the command with ..

The dot command can also take a count so 5. will repeat the last command 5 times.

You may also want to have a look at unimpaired.vim as it has the following mapping:

]<Space> - Add [count] blank lines below the cursor.

Since it is a mapping you can also provide a count. e.g. 5]<space>

unimpaired.vim also has many other convenient mappings. e.g. ]a for :next and ]b for :bnext`


I can't think of any way which does not involve a mapping or function :

:noremap <leader>o o<ESC>
:noremap <leader>O O<ESC>

With this, you can type 5\o to insert 5 blank lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜