简体   繁体   中英

How do I map <q-1> to close file opened in vim?

I'm working with a particularly stubborn keyboard where the SHIFT key simply doesn't seem to stay down when I need it to, especially when I'm typing stuff that includes keys that are further towards the top of the keyboard. Typing '~' somehow almost always types '`', and typing special characters almost always leads to the corresponding numbers being typed eg. when I try to type '@' I get '2','4' for '$' and so on

I primarily use vim these days, and was wondering is it's possible to map to so that when I want to close a file without writing, I can do it without having to worry about whether I have typed '1' or '!'

Help much appreciated

If you are able to enter colon easily then you can add cnoremap q1 q! to your .vimrc so it wouldn't matter if you entered ! or 1 at the end of a command. If colon is also a difficult to enter character then you can create mapping in the normal mode by adding noremap q1 :q!<CR> . Obviously you can create both mappings.

However i'd think of a new keyboard (:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM