I have reassigned ;
to :
in Vim. I am constantly saving my code using :w
. When I am in the insert mode, after making some changes, due to my muscle memory, I type ;w
to save the document, but it adds ;w
text in the code. Is it possible to assign ;w
in insert mode to exit and save the document. If there is a better method, please let me know.
You can remap :
and ;
at the OS level, and just get used to it. I started that some months ago and the adjustment was fairly smooth. Now I love it. Not sure what OS you're on, but I'm sure there's a solution for any. In X, you'd use xmodmap
. In my ~/.xinitrc
I have (among many remappings):
# Swap ; and :
xmodmap -e "keycode 47 = colon semicolon"
Use xev
to see what exactly your keycodes are.
:inoremap ;w <esc>:w<cr>i
save buffer and return to insert mode
:inoremap ;w <esc>:wq<cr>
save and close buffer (exit vim if buffer only one).
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.