[英]How can I filter the content of a register in vim?
system()是要走的路。 :h system()
。
您可以使用旧时尚方式(一种可以完全控制的方式,因为您可以根据需要进行多次管道和重定向):
:let res = system("echo ".shellescape(@+)." | the-filter-command")
:put=res
但是,你可能有行结束(最后一个字符必须chomped)的问题。 因此,第二个解决方案,其中vim使用临时文件并将其传递给过滤器程序:
:let res = system(the-filter-command, @+)
:put=res
如果您使用另一个缓冲区,还有另一种方法可以实现此目的:
:new
:put=@+
:%!the-filter-command
:%d +
:bd
:put=@+
最后一点:Vim已经有了一些自己的过滤器:sort
, uniq
本身也是可能的 (但有点复杂),...
:let @a = system("ls -l " . shellescape(@+))
似乎在这里工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.