Remapping :Wq to :wq in vim

后端 未结 3 1155
醉酒成梦
醉酒成梦 2021-01-04 10:48

A lot of times, when I want to save a file in vim and immediately exit thereafter, I accidentally type :Wq instead of :wq.

Vim naturally gives me this error:

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 11:22

    Though abbreviations suggest themselves for this (:cnoreabbrev Wk wk), their main disadvantage is that they are also applied in other places, such as when using Wk in a search pattern.

    With the cmdalias plugin, you can define an alias:

    :Alias Wk wk
    

    PS: There is no :wk command, did you mean :wn[ext]? For a simple :w, have a look at this question

提交回复
热议问题