vim 中有没有办法让 :W 做与 :w 相同的事情? [英] Is there a way in vim to make :W to do the same thing as :w?

查看:19
本文介绍了vim 中有没有办法让 :W 做与 :w 相同的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:q 和 :Q 也是如此.我几乎总是不会足够快地停止轮班,看到 :Q 和 :W 无论如何都没有被使用,我认为让它们与小写对应物做同样的事情会很好.

The same goes for :q and :Q. I almost always don't let up on shift quick enough and seeing that :Q and :W aren't used anyway I thought it would be nice to just have them do the same as their lower-case counterparts.

推荐答案

hack 是通过 :cmap:cabb 进行的,但这些都有副作用(即其他实例也会被无意中转换).

The hack is via a :cmap or :cabb, but these have side effects (i.e. other instances will be inadvertently converted, too).

cmdalias 插件在这方面做得更好.

但我认为对于您的用例,最好定义您自己的大写命令变体.主要挑战是支持原始选项的所有选项:

But I think for your use case it's best to define your own uppercase command-variants. The main challenge is to support all the options that the original one has:

command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>

这篇关于vim 中有没有办法让 :W 做与 :w 相同的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆