views:

35

answers:

1

I have a Vimscript function defined like this:

function Cs(a, b)
    normal a:a|"cylr a:b|x"cP
endfunction 

However, the intended action (do some crazy stuff with the arguments a and b in normal mode) doesn't work, instead it takes the first "a" as "append" and writes the rest of the line to the file.

How can I use arguments on a "normal" statement in Vimscript? I found no way to do this.

+2  A: 

You need to build up a string with the parameters in and execute it with the :exec statement.

e.g. something like this:

function Cs(a, b)
    exec "normal " a ":" a "|\"cylr " a ":" b "|x\"cP"
endfunction 
Dave Kirby
You forgot to concatenate the strings with .
Luc Hermitte
@Luc: No I didn't. The exec command will take any number of arguments and concatenate them together without needing to use `.`
Dave Kirby