oal*_*ers 1 vim bash perl exec
我正在开发一个需要vim在任意行和任意列中打开文件的模块。我正在通过进行操作exec(),但vim没有获得正确的行和列:
如果我将其简化为单线:
perl -E "exec(q{vim}, q{+'call cursor(1,3)'}, q{README.md})"
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
"README.md" 116L, 3790C
Error detected while processing command line:
E20: Mark not set
Press ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)
当vim显示此错误时,ps显示vim +'call cursor(1,3)' README.md,这是我想要的命令。实际上,复制/粘贴vim +'call cursor(1,3)' README.md到新的终端窗口中可以使我获得所需的行为。
在我看来,vim当通过Perl的命令运行命令时,该行是116,而不是1,该列是3790,而不是3 exec()。
这是Perl 5.26.1,Vim 8.1和GNU bash版本3.2.57(1)-发行版(x86_64-apple-darwin18)。
bash命令
vim +'call cursor(1,3)' README.md
Run Code Online (Sandbox Code Playgroud)
没有什么不同
vim '+call cursor(1,3)' README.md
Run Code Online (Sandbox Code Playgroud)
两者都vim使用以下参数启动:
0:vim
1:+call cursor(1,3)
2:README.md
但是,您指示Perl将以下args传递给vim:
0:vim
1:+'call cursor(1,3)'
2:README.md
该Shell命令的Perl等效为
exec('vim', '+call cursor(1,3)', 'README.md')
Run Code Online (Sandbox Code Playgroud)