In vim, in my .vimrc, how can I redefine a command (i.e. :e) as something else?
I want to redefine :e *
as :tabe *
.
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
- PowerShell Pass Named parameters to ArgumentList
- How to copy the value of a vim option to a registe
- Adb install progress bar
As I understand it, you can't. User defined commands must have an uppercase first letter.
for more information
I figured out a way to do it. See How to disable a built-in command in vim . From that, we can see that we can use cabbrev to change what a command does. For my needs,
cabbrev e tabe
is perfect.But we can generalize this solution to make commands starting with lower case characters accessible to users for user-defined ones: use cabbrev to (re)define a built-in command as a user-defined one. As such, we are able to redefine built-in commands as well as user-defined ones.
Here's an example, which is equivalent to my aforementioned solution to my problem:
That's all.
cnoreabbrev
workaroundThe best workaround without a plugin that I have seen so far is:
If you use a simple:
as suggested by @Yktula would break your command if you want to do:
which would become:
instead.
As explained by @pydave in the comments, the cmdalias plugin adds a simpler interface to doing the safe alias simply as:
At the time of writing the plugin also uses the
getcmdtype() == ":"
technique to implement its functionality.