I have created a simple user-defined command using the following vim script
command! -nargs=* -complete=file EE :call EE(<f-args>)
function! EE(...)
if filereadable(expand(a:1))
exec 'edit ' . a:1
endif
endfunction
:EE file
will open a file (like the built-in command ":edit file
)
But unlike :tab edit file
the command :tab EE file
will not open a new tab.
Is it possible to enhance the script so that a "prefix" like :tab
or :vert
could be used?
No, unfortunately, the prefix command isn't exposed to custom commands; it would be great to have a v:prefixcommand
variable that one could evaluate.
You so far have to write separate alternative commands, eg :TEE
for :tab EE
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.