简体   繁体   中英

Using Register Variables in VimScript

I have the following code in vim Script(File name: file):

:execute "normal /\This\<CR>gg"
:let i=1
:execute "normal nxxcwThat".@=i

I am executing this code on the following file(File name: out):

This is line 1
This is line 2

I am using the following run command:

vim -s file out

And the output is:

This is line 1
That 1 is line 2

I do not understand why is space getting printed between That and 1 .
Also, I am slightly confused in how to use register variables when writing a vimscript. Could someone please explain?

That might be a bug. But is there a reason, you are using the expression-register to access the variable?

What works is to use, which looks more readable anyhow:

:execute "normal nxxcwThat".i

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM