> While the :echo command takes an expression, the :cs add command takes
> a file name. The commands expect completely different arguments. You
> will NEED to use :exec in order to dynamically build a :cs command.
I think the analogy to lisp macros actually is quite adequate since it
seems to be the command that is responsible for how to parse the
arguments -- the upside of which is that you can actually create neat
DSLs in vimscript. It seems that :cs takes several optional arguments,
which is probably why you'd have to escape blanks in command
arguments.
E.g.:
command -nargs=1 Narg1 echo [<f-args>]
command -nargs=+ NargPlus echo [<f-args>]
command -nargs=+ NargEval echo eval(<q-args>)
Narg1 1 + 2 + 3
#=> ["1 + 2 + 3"]
NargPlus 1 + 2 + 3
#=> ["1", "+", "2", "+", "3"]
NargEval 1 + 2 + 3
#=> 6
I personally wish that for every :ex command there were a
corresponding function. In vim7.2, vim got 2 new functions for
escaping command arguments (shellescape and fnameescape) that are used
in conjunction with exec but since the precise rules of how arguments
are interpreted by the commands aren't always that obvious, it
sometimes is a matter of trial and error to find out which escape
function you have to use for which command. A function that
corresponds to the command with the same name would be easier to use.
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php