在脚本中,我有以下不起作用的代码:
set eval(rules[formatoption])=value
whererules
是字典,formatoption
andvalue
是变量。我想让 Vim 从中读取变量名rules[formatoption]
并将其设置为value
. 如何让 Vim 以这种方式设置变量?我认为应该有一个类似setvar(name, value)
或类似的函数,将name
(string) 设置为value
. 那行代码将使我免于在 70 行脚本中编写大约 30 行代码。