I want to map
:e file.txt to
:tabnew file.txt, or the equivalent setting for editing file in a new tab. What do I need to put into my vimrc?
You probably want to read
:h user-commands and put the following in your vimrc:
command! -nargs=1 -complete=file E tabnew <args>
You can't override
:e but you can create the command
:E which will take one argument (
-nargs=1), complete this argument as
tabnew does (
-complete=file) and executes
tabnew with the argument it took.
However as @Hotschke said in comments you probably don't need such a command.
Like everyone else, I recommend pretty strongly against doing this, but if you're dead set on the idea (and for future readers who might be doing something slightly different) you could use something like:
:cabbrev <expr> e getcmdline() == 'e' && getcmdtype() == ':' ? 'tabnew' : 'e'
This will replace
:tabnew as soon as you type the space after the
e. If you find the change too visually jarring, you could perhaps instead set up the the
E command from statox's answer and convert
:help :cabbrev for more details.