vi command for adding blank line?

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.


Part of the allure of using VI is having a command mode for manipulating the text, and an edit mode for adding text. This keeps you from having to hit CTRL-whatever to accomplish things.

The other suggestions may work - I haven't tried them - but they seem to require quite a few characters or manipulating your VI environment too much.

Try using o[ESC] followed by a . for each new line you want to add, or 5. to add 5 lines. This is much faster, and will always work on any install of VI.


In vim, there's also :normal o or :normal O.

Tags:

Vi

Vim