No edit summary |
(move see also to its own section and use intrawiki link) |
||
Line 11: | Line 11: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | |||
− | * Similar to http://vim.wikia.com/wiki/Use_Return_and_Delete_keys_in_normal_mode_like_in_insert_mode |
||
As you all may know with 'o' or 'O' you can insert a new line after/before the current line. But both commands enter the insert mode, which may sometimes not what you want. I put this in my vimrc-file to insert a new-line after the current line by pressing Enter (Shift-Enter for inserting a line before the current line): |
As you all may know with 'o' or 'O' you can insert a new line after/before the current line. But both commands enter the insert mode, which may sometimes not what you want. I put this in my vimrc-file to insert a new-line after the current line by pressing Enter (Shift-Enter for inserting a line before the current line): |
||
Line 27: | Line 25: | ||
map <CR> o<Esc>k |
map <CR> o<Esc>k |
||
</pre> |
</pre> |
||
+ | |||
+ | ==See also== |
||
+ | * [[Use Return and Delete keys in normal mode like in insert mode]] |
||
==Comments== |
==Comments== |
Revision as of 21:19, 28 March 2012
created September 3, 2005 · complexity basic · author Christopher Auer · version 5.7
As you all may know with 'o' or 'O' you can insert a new line after/before the current line. But both commands enter the insert mode, which may sometimes not what you want. I put this in my vimrc-file to insert a new-line after the current line by pressing Enter (Shift-Enter for inserting a line before the current line):
map <S-Enter> O<Esc> map <CR> o<Esc>
If you want to stay in the line where you have been before use the following maps:
map <S-Enter> O<Esc>j map <CR> o<Esc>k
See also
Comments
It's also a nice idea to map something like
nnoremap <C-J> a<CR><Esc>k$
because it's the opposite of Shift-J. A more sophisticated solution would be
nnoremap <C-J> ciW<CR><Esc>:if match( @", "^\\s*$") < 0<Bar>exec "norm P-$diw+"<Bar>endif<CR>
For whatever reason, I was unable to get the suggest mapping with <S-Enter> and <CR> to work properly (both ended up inserting below). So I did:
map <F8> o<Esc> map <F9> O<Esc>
Which works fine for me.
<S-Enter> and <CR> will work separately in gvim but not in urxvt. See http://stackoverflow.com/questions/598113/can-terminals-detect-shift-enter-or-control-enter
Since I have inoremap jj <Esc>
in my .vimrc
, it take not too much to type ojj
or Ojj
.