Martín Fixman
Martín Fixman

Reputation: 9595

Using an argument of a function in normal mode in Vim?

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.

Upvotes: 0

Views: 400

Answers (1)

Dave Kirby
Dave Kirby

Reputation: 26582

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 

Upvotes: 2

Related Questions