开发者

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.


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 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜