In vim, in my .vimrc, how can I redefine a command (i.e. :e) as something else?
I want to redefine :e *
as :tabe *
.
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:
:command -nargs=+ E :tabe "<args>"
:cabbrev e E
That's all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With