What is the purpose of user
command in Vi/Vim? I noticed that a lot of commands are usually used to call functions like this:
command! TrimWhitespace call TrimWhitespace()
From my observation,
command seems to provide quick way to call a function without having to type
call from the command mode.
But I also see example like this, which executes Vim commands.
command! Vimrc :vsplit $MYVIMRC
Vim's help page is quite terse and confusing on this subject and I would like more clarification. Are these ex commands or Vimscript? In Vim's help page, I see more complex examples like this (not that I want to know what it does, but rather why we use them):
command! -nargs=+ -complete=file MyEdit \ for f in expand(<q-args>, 0, 1) | \ exe '<mods> split ' . f | \ endfor function! SpecialEdit(files, mods) for f in expand(a:files, 0, 1) exe a:mods . ' split ' . f endfor endfunction command! -nargs=+ -complete=file Sedit \ call SpecialEdit(<q-args>, <q-mods>)