Skip to main content
Rearranged comments above important notes and condensed wording.
Source Link

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 :dis or :registers.

  • :pu is the equivalent shortcut command.

  • Type :help put or :help registers for 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 =test and :put =" in succession then the output below the current line will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is 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 o and :r !echo respectively 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 :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the " unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; 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 using a script is overkill.

  • @Glorytoad and @Hakim suggest using o[Esc] which puts Vi into edit mode. 

  • You can use the equivalent :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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 ", in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the unnamed register ", type :let @"=''.  

  • Check the contents of the Vim registers with :dis or :registers.

  • :pu is the equivalent shortcut command.

  • Type :help put or :help registers for 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 =test and :put =" in succession then the output below the current line will be:

    test test 
  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important caveats; and the latter having an equivocal instruction on how to specify an insertion point: "... specify a line at the start".

  • @Steven Pritchard's and @Jeff Schaller's answers using :normal o and :r !echo respectively are good alternatives.

  • Using a script as suggested by @Ingo Karkat is overkill.

  • @Glorytoad and @Hakim use o[Esc] which puts Vi into edit mode. 

Remove comment on Akhilesh Siddhanti's solution.
Source Link

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the """ unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; and the latter having an equivocal instruction on how to specify an insertion point: "... specify a line at the start".

  • @Akhilesh Siddhanti's answer causes the deletion of a character.

  • @Ingo Karkat may have a script to download that works but I think using a script is overkill.

  • @Glorytoad and @Hakim suggest using o[Esc] which puts Vi into edit mode. 

  • You can use the equivalent :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the "" unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; and the latter having an equivocal instruction on how to specify an insertion point: "... specify a line at the start".

  • @Akhilesh Siddhanti's answer causes the deletion of a character.

  • @Ingo Karkat may have a script to download that works but I think using a script is overkill.

  • @Glorytoad and @Hakim suggest using o[Esc] which puts Vi into edit mode. 

  • You can use the equivalent :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the " unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; 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 using a script is overkill.

  • @Glorytoad and @Hakim suggest using o[Esc] which puts Vi into edit mode. 

  • You can use the equivalent :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

Changed the reference name of the "" unnamed register to the one used in the Vim help manual.
Source Link

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the "" unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; and the latter for beinghaving an equivocal instruction on how to specify an insertion point: "... specify a line at the start".

  • @Akhilesh Siddhanti's answer causes the deletion of a character.

  • You can use the equivalent :pu shortcut command.

  • @Ingo Karkat may have a script to download that works but I think using a script is overkill.

  • @Glorytoad suggestsand @Hakim suggest using o[Esc] which puts Vi into edit mode.  This is contrary to 

  • You can use the OPequivalent (original post) which states "I want to stay in:pu shortcut command mode".  @Hakim's answer, which is similar, also puts you into edit mode.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the "" unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; and the latter for being equivocal on how to specify an insertion point: "... specify a line at the start".

  • @Akhilesh Siddhanti's answer causes the deletion of a character.

  • You can use the equivalent :pu shortcut command.

  • @Ingo Karkat may have a script to download that works but I think using a script is overkill.

  • @Glorytoad suggests o[Esc] which puts Vi into edit mode.  This is contrary to the OP (original post) which states "I want to stay in command mode".  @Hakim's answer, which is similar, also puts you into edit mode.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

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, in which case you should use :put ='' which contains two single quotes as the expression.  

  • To clear the "" unnamed register, type :let @"=''.  

  • You can check the contents of the Vim registers with :dis or :registers.

  • @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 =test and :put =" in succession then the output will be:

    test test 
  • @Steven Pritchard's answer using :normal o is a good alternative.

  • @Jeff Schaller's answer using :r !echo is also a good alternative.

  • This answer is an improvement upon that of @Mr Shunz and @justerman, the former omitting some important warnings; and the latter having an equivocal instruction on how to specify an insertion point: "... specify a line at the start".

  • @Akhilesh Siddhanti's answer causes the deletion of a character.

  • @Ingo Karkat may have a script to download that works but I think using a script is overkill.

  • @Glorytoad and @Hakim suggest using o[Esc] which puts Vi into edit mode. 

  • You can use the equivalent :pu shortcut command.

  • Type :help put or :help registers for more information on this topic.

  • Vim version 7.2 was used in my testing.

Changed the reference name of the "" unnamed register to the one used in the Vim help manual.
Source Link
Loading
Removed some unnecessary wording and comments.
Source Link
Loading
Added caveats regarding registers.
Source Link
Loading
Alternate wording and better adjectives in the discussion; added help info.
Source Link
Loading
@muru, you introduced an error into my code when you removed the blockquotes because I had escape char "\" ! It should be `:23put! =repeat(\"\n\",5)` but you made it `:23put! =repeat(\\\"\n\\\",5)`. Added simple eg.1, corrected code for eg.2 with a colon at the beginning of the command.
Source Link
Loading
@muru, you introduced an error into my code when you removed the blockquotes because I had escape char "\" ! It should be `:23put! =repeat(\"\n\",5)` but you made it `:23put! =repeat(\\\"\n\\\",5)`. Added simple eg.1, corrected code for eg.2 with a colon at the beginning of the command.
Source Link
Loading
use code formatting for commands and output
Source Link
muru
  • 78.3k
  • 16
  • 214
  • 320
Loading
Added simple example 1. Corrected answer for example 2 with a colon at the beginning of the command.
Source Link
Loading
Reword "flawed" to "@Mr Shunz's answer has a caveat (flaw)"
Source Link
Loading
Grammar "who provided some ..."
Source Link
Loading
Source Link
Loading