To insert a blank line below the current line use :put, or :put! to insert one above.
To specify where to insert the blank line (nth line) use :[n]put.
e.g.1: Add a blank line below line number 23 while in command mode.
:23put e.g.2: Add 5 blank lines above line number 23 while in command mode.
:23put! =repeat(\"\n\",5) Notes and warnings:
For the output of a single empty line you do not need to use the
=feature unless there is a value stored in the unnamed register"unnamed register, in which case you should use:put =''which contains two single quotes as the expression.To clear the unnamed register
"unnamed register, type:let @"=''.You can checkCheck the contents of the Vim registers with
:disor:registers.:puis the equivalent shortcut command.Type
:help putor:help registersfor more information on this topic.Vim version 7.2 was used in my testing.
@Mr Shunz's answer has a caveat. If you use the double quotes as the expression i.e.
:put =", then the previous expression will be used. E.g. when you enter:put =testand:put ="in succession then the output below the current line will be:test test@Steven Pritchard's answer using
:normal ois a good alternative.@Jeff Schaller's answer using
:r !echois also a good alternative.This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings;caveats; and the latter having an equivocal instruction on how to specify an insertion point: "... specify a line at the start".
@Ingo Karkat may have a script to download that works but I think@Steven Pritchard's and @Jeff Schaller's answers using
:normal oand:r !echorespectively are good alternatives.Using a script as suggested by @Ingo Karkat is overkill.
@Glorytoad and @Hakim suggest usinguse
o[Esc]which puts Vi into edit mode.You can use the equivalent
:pushortcut command.Type
:help putor:help registersfor more information on this topic.Vim version 7.2 was used in my testing.