Title: Map :E to :Explore in command mode?
Tags: vim
Question: 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&gt; :Explore<CR&gt;
cmap :E^M :Explore^M
(where ^M = control-v + enter) but these don't work unless I hit enter really really fast.

Here is the accepted answer: :E would normally suffice as is if :Explore were the only defined command that began with an E. You evidently have multiple such commands defined, so :E is ambiguous and results in an error.
:cmap causes 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:
cabbrev E Explore
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 :E to be properly aliased to :Explore, it must be defined as a separate command:
command! E Explore
However, :command E, which lists all defined commands that start with E, reveals that :E and :Explore have different properties. For example, it's impossible to execute :E ~ because :E does not accept any arguments. Also, unlike :Explore, :E does not autocomplete directories.
To remedy these deficiencies, :E must be defined in exactly the same way as :Explore. Executing :verbose command Explore shows the location of the script in which :Explore is defined; :E can then be defined in the same manner, with the addition of <args&gt;:
command! -nargs=* -bar -bang -count=0 -complete=dir E Explore <args&gt;
While it's possible to deduce most of these attributes from the information provided by :command Explore, there can still be discrepancies, such as -bar in this case.
N.B. If :Explore and :Example are defined, :Exp and :Exa are the shortest unambiguous commands that can be used. Explicitly aliasing :E to one of them, as above, overrides Vim's default behavior and allows for disambiguation. However, :Ex would still be ambiguous.
Comment for this answer: For the complete n00b, put `command! E Explore` in your `~/.vimrc` file, then :E will properly alias to :Explore.
Comment for this answer: @PeterRincker Neat, but for a totally different use case.
Comment for this answer: Another quick way to open up the explorer is using `:e.`. This will `:Explore` the current directory. This also has the nice benefit of not needing the shift key.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:01/16/13', 'FavoriteCount': 7.0, 'PostTypeId': 1, 'Tags': '<vim>', 'Title': 'Map :E to :Explore in command mode?', 'ViewCount': 7760, 'id': 14367440, 'user_AboutMe': "<p>I'm an astrophysicist using primarily python.</p>\n", 'user_AccountId': 430749.0, 'user_DisplayName': 'keflavich', 'user_Reputation': 17409.0, 'user_Views': 605.0, 'user_id': 814354.0}}