I have one question about Vim. I understood map as just the equal command till now. Here's the thing. I put imap <co> <esc>o
in my .vimrc
file to start a new line. As to the reason why not just map <CR>
is that I followed the suggestion by Drew Neil that using esc
and o
command to replace so that I can use undo
command line by line. However, when I use <co>
to start a line, the undo
command doesn't work, which means Vim doesn't switch the mode even I map the <esc>
! I don't know whether is feature or bug of Vim? I will appreciate it if you help me in some ways.
You can use inoremap <co> <cg>u<esc>o
to get the desired behaviour you want. <cg>u
breaks the current undo sequence (see :h i_CTRL-G_u
).
I actually never thought about why having <esc>
in insert mappings doesn't count as breaking the undo sequence. I could certainly theorize why but doing so is dangerous in an SO answer, so I won't :)
Edited to add: Simpler would be: inoremap <co> <cg>u<cr>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.