Pass args to a custom vim command
Custom commands are easy in vim:
:command HelloWorld echo "hello world"
:HelloWorld
" outputs hello world
But what if I want to pass an arg to the command?
First you have to specify that you want args with the -narg
flag. Then you need to have declare where the args would go with <q-args>
.
:command! -narg=1 Say :echo "hello" <q-args>
:Say world
" outputs hello world
Tweet