When I type :e, MacVim automatically expands this to :Edit. The problem with this is that I can’t discard my current buffer with :Edit!, because I get an error message saying that “!” isn’t allowed.
I have two questions:
- Why does :edit! work and not :Edit!
- Is there a way to disable this auto-expand feature in MacVim, or perhaps switch it to expand to :edit! and not :Edit! ?
Thanks!
If the expansion happens immediately after typing the
e, it might be due to a command-mode mapping (i.e.:map!,:cmapor:lmap). If it is only expanded after typingefollowed by a space (or enter), then it might be an abbreviation (i.e.:abbreviateor:cabbrev).You can temporarily avoid a mapping-based expansion by typing Control‑V or Control‑Q before
e. Another workaround is to type Control‑F while entering a command-line command (i.e. you are at the:prompt; or typeq:instead of:when starting a command). This will bring up the command-line window so that you can edit your command via normal/insert modes (this avoids all command-line mode mappings).Once you have a way to enter
einto a command-line again, you can use:verboseto find the source of the mapping:(You must either use the command-line window to type this literally, or enter it at the command-line by typing a Control‑V or Control‑Q before each
e.)This will show you the definition of the mapping. Additionally, if it came from a plugin, then the source will be identified with a second line like
Last set from /path/to/some/file.Checking for an abbreviation is a bit tricker since there are two chances for expansion (while typing and when the command line is being parsed):
The
^Vneeds to be an actual Control‑V. Usually you accomplish this by typing Control‑V twice (or Control‑Q, then Control‑V).As for the
Editcommand itself, it is not a built-in command, so something plugin must be defining it. Very few built-in commands start with an uppercase letter, and all “user defined” commands must start with one; see:help E183.You can use
:verboseagain to find where:Editwas defined:I suspect the mapping/abbreviation and the command probably come from the same place.
You can manually disable a mapping-based expansion with
:cunmapand an abbreviation-based expansion with:cunabbrev:Again, you may need type Control‑V or Control‑Q before each
e, and the^Vmust be a literal Control‑V (type Control‑V twice to enter it).Unfortunately, you can not just put these in your
~/.vimrcif the definitions are coming from a plugin because plugins are loaded after~/.vimrc. You should investigate the plugin to see if it offers a option to disable the intrusive mapping. Sometimes plugins check a:letvariable to see if they should enable some feature. Maybe your problematic plugin has a “knob” that will let you tell it not to install itse->Editexpansion. If not, you might be able to report a bug about:Edit!not working properly and ask for a way to disable the expansion too.