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:
- W开发者_JAVA百科hy 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!
, :cmap
or :lmap
). If it is only expanded after typing e
followed by a space (or enter), then it might be an abbreviation (i.e. :abbreviate
or :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 type q:
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 e
into a command-line again, you can use :verbose
to find the source of the mapping:
:verbose cmap e
(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):
:verbose cab ^Ve
The ^V
needs to be an actual Control‑V. Usually you accomplish this by typing Control‑V twice (or Control‑Q, then Control‑V).
As for the Edit
command 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 :verbose
again to find where :Edit
was defined:
:verbose command Edit
I suspect the mapping/abbreviation and the command probably come from the same place.
You can manually disable a mapping-based expansion with :cunmap
and an abbreviation-based expansion with :cunabbrev
:
:cunmap e
:cunabbrev ^Ve
Again, you may need type Control‑V or Control‑Q before each e
, and the ^V
must be a literal Control‑V (type Control‑V twice to enter it).
Unfortunately, you can not just put these in your ~/.vimrc
if 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 :let
variable to see if they should enable some feature. Maybe your problematic plugin has a “knob” that will let you tell it not to install its e
-> Edit
expansion. 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.
Do you use TextExpander, Typinator or some text expansion utility? If yes, those might be the culprit. As far as I know, MacVim does not expand text like that.
精彩评论