如何将映射到在vim中打开的关闭文件?

时间:2020-12-05 03:59:13

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

我正在使用一个特别顽固的键盘,当我需要它时,SHIFT键似乎根本不会停留,尤其是当我输入的内容包括键盘顶部的键时。键入'〜'几乎总是键入''',键入特殊字符几乎总是会导致输入相应的数字,例如。当我尝试键入'@'时,我得到'2','4'代表'$'等等

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 '!'

这些天我主要使用vim,并且想知道是否可以映射到这样当我想要在没有写入的情况下关闭文件时,我可以做到这一点,而不必担心我是否键入了'1'或'!'

Help much appreciated

非常感谢

1 个解决方案

#1


1  

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.

如果你能够轻松输入冒号,那么你可以添加cnoremap q1 q!你的.vimrc所以如果你输入就没关系了!或命令结尾处的1。如果冒号也难以输入,那么您可以通过添加noremap q1:q! 在正常模式下创建映射。显然,您可以创建两个映射。

However i'd think of a new keyboard (:

不过我会想到一个新的键盘(:

#1


1  

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.

如果你能够轻松输入冒号,那么你可以添加cnoremap q1 q!你的.vimrc所以如果你输入就没关系了!或命令结尾处的1。如果冒号也难以输入,那么您可以通过添加noremap q1:q! 在正常模式下创建映射。显然,您可以创建两个映射。

However i'd think of a new keyboard (:

不过我会想到一个新的键盘(: