[英]Is there a way to rename vim commands?
I easily found how to remap keys in my vimrc, but not how to change commands like :badd
, :new
... to be for example :bd
, :n
... 我很容易找到如何在vimrc中重新映射键,但没有找到如何更改:badd
, :new
...之类的命令,例如:bd
, :n
...
Can someone show me how to do this, or give me a link to a page that shows it? 有人可以告诉我如何执行此操作,也可以给我提供指向显示该操作的页面的链接吗?
Use :command!
使用:command!
. 。 For example, if you want to be able to type :W<cr>
in addition to :w<cr>
to save your file you would add the following line to your vimrc 例如,如果您希望能够输入:W<cr>
除了:w<cr>
保存文件,需要将下面一行添加到您的vimrc
command! W w
The exclamation point makes the command mapping non-recursive, similar to noremap
vs. map
. 感叹号使命令映射成为非递归的,类似于noremap
vs. map
。 Further, commands you define must start with a capital letter . 此外,您定义的命令必须以大写字母开头 。 This stops them from overlapping with built-in commands. 这样可以防止它们与内置命令重叠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.