VIM:将外部命令的输出存储到寄存器中 [英] VIM: store output of external command into a register
本文介绍了VIM:将外部命令的输出存储到寄存器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以运行外部命令并将其输出存储在寄存器中?
Is it possible to run an external command and store its output in a register?
:redir
适用于 ex 命令,不适用于外部命令 (afaik):r !
运行外部命令但直接将输出插入到当前缓冲区
:redir
works for ex commands, not for external commands (afaik):r !
runs the external command but directly inserts output into the current buffer
推荐答案
感谢 vim-use 邮件列表中的一位用户找到了答案:
Found the answer thanks to a user on the vim-use mailing list:
:let @a = system("ls -l")
以光标下的文件作为参数运行命令:
To run a command with the file under the cursor as argument:
:let @a = system("ls -l " .shellescape(expand('<cfile>')))
这篇关于VIM:将外部命令的输出存储到寄存器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文