I wonder if I can insert a new line without leaving normal mode. For example, I have two lines:

this is line one
this is line two

And the cursor is on line one. Now I want a new line between line one and line two, like this:

this is line one

this is line two

I know that when I am in normal mode, I can simply press o. But this would enter insert mode.

How can I insert a new line like and stay in normal mode?

11 Answers 11


I use a mapping for that:

" Quickly insert an empty new line without entering insert mode
    nnoremap <Leader>o o<Esc>
    nnoremap <Leader>O O<Esc>

This way you can insert a line under your cursor with <Leader>o and one on the previous line with <Leader>O.

Note: One could argue that it requires as many keystrokes as o<Esc> but hopefully you choosed your leader to make this kind of mapping easy. Also I'm really not sure there is a built-in way to do this.

| improve this answer | |

A solution that doesn't go through insert mode, doesn't move the cursor, and allows you to use a counter to append several lines at once (3\o etc.):

nnoremap <silent> <leader>o :<C-u>call append(line("."),   repeat([""], v:count1))<CR>
nnoremap <silent> <leader>O :<C-u>call append(line(".")-1, repeat([""], v:count1))<CR>
| improve this answer | |
  • That is a great solution, I even prefer using oo and OO instead of <leader>o – Walker Boh Dec 31 '19 at 9:33

If you don't want to add mappings, you can yank yy an empty line and then pasted p for below cursor and P for above the cursor.

| improve this answer | |
  • This is probably the best answer without mapping. – Willem van Ketwich Jan 3 '18 at 9:31
  • 1
    Or save it to the o register with "oyy and paste it from there whenever needed with "op. – mike23 Dec 3 '19 at 20:36

I personally recommend using Tim Pope's Unimpaired plugin. It provides many mappings but the ones you will looking for are [<space> and ]<space> which create blank lines above and below the current line respectively. Unimpaired also provides nice mappings for moving through the quickfix list, buffer list, option toggling, and many others. See :h unimpaired for more.

If you do not want to use unimpaired plugin but like the mappings below are some quick mappings to put in your ~/.vimrc file:

nnoremap <silent> [<space>  :<c-u>put!=repeat([''],v:count)<bar>']+1<cr>
nnoremap <silent> ]<space>  :<c-u>put =repeat([''],v:count)<bar>'[-1<cr>
| improve this answer | |

My mapping uses Shift-Enter. It differs from the others in that the cursor is returned to the same line and column using mark o.

" Insert new line above without going into insert mode
" (uses mark o to return to the previous cursor column)
nnoremap <S-Enter> moO<Esc>`o
| improve this answer | |
  • 6
    Note that mapping <S-Enter> doesn't work in terminal emulators (it only works in gVim). So you'll need to choose a diffferent key combination to map it to ;-) – Martin Tournoij Jul 8 '15 at 7:42

This answer by Maxim Kim was life-changing:

noremap <silent> <space> :exe "normal i".nr2char(getchar())<CR>

and my riff on it:

noremap <silent> <s-space> :exe "normal a".nr2char(getchar())<CR>

Put those lines in your vimrc. Then go to the beginning of the second line of your file and hit Space, Enter, or go to the end of the first line and hit Shift+Space, Enter. Either will add the empty line between the first and second lines, and leave you in normal mode.

You can also use these for any other single key - hit Space or Shift+Space followed by the key you want and it will insert or append it, respectively.

| improve this answer | |

These mappings will do exactly what you are looking for.

nnoremap <c-n> @="m`o\eg``"<cr>
nnoremap <c-p> @="m`O\eg``"<cr>   

These insert n number of newlines before or after the cursor; keeping the cursor exactly where it is, without changing the jump list.

Another solution is to just make a shortcut that fills the unnamed register with a newline. Then you can just use the put commands, p or P to insert newlines. For example:

nnoremap "<cr> :let @@="\n"<cr>
| improve this answer | |

I use the Vim extension in Visual Studio Code, and I can insert a new line while staying in normal mode with Ctrl+Enter.

| improve this answer | |
New contributor
zrodr22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    Welcome to Vi and Vim! I’ve edited your post with a little bit of formatting. Note that what you’re describing sounds a lot like a VSCode-specific key sequence, as that shouldnt work by default in vim. – D. Ben Knoble Aug 4 at 23:24
  • I have been trying to find, is this behaviour in VSCode because of a plugin? Do you have any idea? – Hamza Zubair 1 hour ago

My mapping for this

 " Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>k
nnoremap <silent> zk O<Esc>j

Different from statox's as this keeps the cursor at the same location.

| improve this answer | |
  • what does <silent>mean? – Alex Jul 8 '15 at 2:39
  • It prevents echoing anything to the status line. I'm pretty sure it doesn't do anything in this specific case, it was just there wherever I originally copied it from, long ago. See :h map-silent. – Kevin Jul 8 '15 at 2:42

My personal solution sticks a newline character into the expression register and pastes it after the current line, then jumps back to the original position:

nnoremap K m`"="\n"<CR>p``
| improve this answer | |

I think the easiest is of course o and then Esc and then for as many lines as you need, you either keep pressing . or do it like 5. (say if you want 5 blank new lines)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.