Vi command for adding blank line

vivim

In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this?

In googling, I'm seeing suggestions to add stuff to my vimrc, but it seems like there should be an easier way (that will always work.)

Best Answer

According to the VIM FAQ you can use the :put command:

12.15. How do I insert a blank line above/below the current line without entering insert mode?

You can use the ":put" ex command to insert blank lines. For example, try

:put =''
:put! =''

For more information, read

:help :put

but then really it's easier to add:

map <Enter> o<ESC>
map <S-Enter> O<ESC>

to your .vimrc. This way you can press Enter or Shift-Enter in normal mode to insert a blank line below or above current line. Of course substitute <Enter> and <S-Enter> with your preferred keys.

Related Question