Vim Tips Wiki

Insert in normal mode

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 604 Printable Monobook Previous Next

created November 18, 2003 · complexity basic · author Sigurd/Yakov Lerner · version 5.7

Inserting an empty lineEdit

With the following map, you can press Enter in normal mode to insert an empty line.

:nmap <CR> _i<Enter><Esc>

Here is an alternative:

" Enter a blank line below/above cursor in Normal mode.
" The o command will continue comments in a program.
nmap ,o o<Esc>k
nmap ,O O<Esc>j

Inserting a spaceEdit

If you manually align text (declarations, ascii tables, trailing comments), you'll find this simple mapping useful.

In normal mode, it inserts a space to push the rest of the line to the right, while leaving the cursor in the same position.

:nnoremap <Space> i<Space><Esc>

For example, suppose we want foo to be aligned with bar:

int   foo;  // ...
double    bar;  // ...

Move the cursor just after 'int'. Press Space until 'foo' is aligned with 'bar'.


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.