nnoremap
nmap, vmap, and imap. These tell Vim to only use the mapping in normal, visual, or insert mode respectively.
Recursion
Run this command:
:nmap dd O<esc>jddk
At first glance it might look like this would map dd to:
Open a new line above this one.
Exit insert mode.
Move back down.
Delete the current line.
Move up to the blank line just created.
Effectively this should "clear the current line". Try it.
Vim will seem to freeze when you press dd. If you press
This mapping is actually recursive! When you press dd, Vim says:
dd is mapped, so perform the mapping.
Open a line.
Exit insert mode.
Move down a line.
dd is mapped, so perform the mapping.
Open a line.
Exit insert mode.
Move down a line.
dd is mapped, so perform the mapping, and so on.
This mapping can never finish running! Go ahead and remove this terrible thing with the following command:
参考:https://learnvimscriptthehardway.stevelosh.com/chapters/05.html
转载请注明:牛哥678 » nnoremap=no recursion map