开发者

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

开发者 https://www.devze.com 2023-01-07 12:12 出处:网络
I have a Vimscript function defined like this: function Cs(a, b) normal a:a|\"cylr a:b|x\"cP endfunction

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

精彩评论

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