hananana hananana - 1 month ago 5
Bash Question

How put variables in :[range]r[ead] !{cmd}

let variable = expand("%:p")
r! myScript path/to/dir variable


I am writing vim-plugin. But there is a problem that can not be solved by all means.

Code I want to do is above code.

Of course, that code return error.

Is way to put variable of VimScripts in "r!"?

PlZ teach me.....

Answer

You can use execute command to include variable namesand registers with other commands.

    : execute('r! '.myscript.path.variablename)

The above command interprets the values of the variables and then executes the command.