"I can't find out how to use a variable out of an inputdialog in a function or for loop. Inputdialog is seen in as a string and I can't use it in a for loop or function.
“我无法找到如何在函数或for循环中使用inputdialog中的变量.Inputdialog被视为字符串,我不能在for循环或函数中使用它。
p.e.:
体育专业:
if !exists("myvar")
let myvar= "which variable?"
endif
let a = inputdialog(myvar)
for n in range(1,3)
put = a
endfor
if p.e. var a = n
I expect this as output:
如果p.e. var a = n我希望这是输出:
1
2
3
but it gives this as output:
但它给出了这个输出:
n
n
n
("a" is seen as string and not as operator)
(“a”被视为字符串而不是运算符)
What did I wrong?
How can I let vim recognize the value of an inputdialog as operator and not as string?
我错了什么?我怎样才能让vim将inputdialog的值识别为运算符而不是字符串?
1 个解决方案
#1
1
Change the command
更改命令
:put =a
to
至
:put =eval(a)
It is also possible to use
它也可以使用
:exe 'put =' a
However, if the string stored in the a
variable contains characters interfering with Ex commands syntax or Command-line mode shortcuts, the above command does not work correctly without escaping said characters.
但是,如果存储在a变量中的字符串包含干扰Ex命令语法或命令行模式快捷方式的字符,则上述命令在不转义所述字符的情况下无法正常工作。
#1
1
Change the command
更改命令
:put =a
to
至
:put =eval(a)
It is also possible to use
它也可以使用
:exe 'put =' a
However, if the string stored in the a
variable contains characters interfering with Ex commands syntax or Command-line mode shortcuts, the above command does not work correctly without escaping said characters.
但是,如果存储在a变量中的字符串包含干扰Ex命令语法或命令行模式快捷方式的字符,则上述命令在不转义所述字符的情况下无法正常工作。