How can I map :E to :Explore? I’ve installed an extension that leads to E464: Ambiguous use of user-defined command if I do :E now, but my fingers won’t forget the command!
I tried map :E :Explore, but that’s ugly since it makes accessing the other commands difficult.
I tried these:
cmap :E<CR> :Explore<CR>
cmap :E^M :Explore^M
(where ^M = control-v + enter) but these don’t work unless I hit enter really really fast.
:Ewould normally suffice as is if:Explorewere the only defined command that began with anE. You evidently have multiple such commands defined, so:Eis ambiguous and results in an error.:cmapcauses immediate literal substitution and thus has unwanted side effects. A slightly better alternative is:cabbrev, which can be used to define abbreviations for command mode:This triggers following EEnter or ESpace. The former is desired because typing :EEnter will invoke
:Explore, but the latter again has side effects in command mode.In order for
:Eto be properly aliased to:Explore, it must be defined as a separate command:However,
:command E, which lists all defined commands that start withE, reveals that:Eand:Explorehave different properties. For example, it’s impossible to execute:E ~because:Edoes not accept any arguments. Also, unlike:Explore,:Edoes not autocomplete directories.To remedy these deficiencies,
:Emust be defined in exactly the same way as:Explore. Executing:verbose command Exploreshows the location of the script in which:Exploreis defined;:Ecan then be defined in the same manner, with the addition of<args>:While it’s possible to deduce most of these attributes from the information provided by
:command Explore, there can still be discrepancies, such as-barin this case.N.B. If
:Exploreand:Exampleare defined,:Expand:Exaare the shortest unambiguous commands that can be used. Explicitly aliasing:Eto one of them, as above, overrides Vim’s default behavior and allows for disambiguation. However,:Exwould still be ambiguous.