Vim: Pipe selected text to shell cmd and receive output on vim info/command line

前端 未结 6 761
时光说笑
时光说笑 2020-12-04 07:57

I want to pipe the selected text to a shell command and receive the one-line output from this shell command on the vim info/command line?

What I\'m really trying to

6条回答
  •  有刺的猬
    2020-12-04 08:38

    Maybe you should use something like

    :echo system('echo '.shellescape(@").' | YourCommand')
    

    Starting from some vim-7.4 version it is better to use

    :echo system('YourCommand', getreg('"', 1, 1))
    

    . This is basically the only way to keep NUL bytes untouched should they be present in the file. Passing @" in one or the other way will transform NUL bytes into NL (newline).

提交回复
热议问题