I am looking for the proper way to specify 'command' argument of the win_execute() function in vim9script.
For example, the following script works fine as a legacy script:
function CheckIndent(lnum) let ind = {} for tif in gettabinfo() for wid in tif.windows call win_execute(wid, 'let ind[wid] = indent(a:lnum)') endfor endfor return ind endfunction echo CheckIndent(5) I converted it to vim9script like this:
vim9script def CheckIndent(lnum: number): dict<number> var ind = {} for tif in gettabinfo() for wid in tif.windows win_execute(wid, 'ind[wid] = indent(lnum)') endfor endfor return ind enddef echo CheckIndent(5) Then, it happens:
E121: Undefined variable: lnum How could I specify lnum as a defined variable in command argument? Is there any workaround or tips?
vim9cmd(or whatever the modifier is)?vim9cmdis supposed (i.e. automatically added) but it is not enough since the local variables are not accessible.