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

前端 未结 6 774
时光说笑
时光说笑 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:20

    For multi line version you can do this after selecting the text:

    :'<,'>:w !command
    

    You can map it to simple visual mode shortcut like this:

    xnoremap c :'<,'>:w !command
    

    Hit leader key + c in visual mode to send the selected text to a stdin of the command. stdout of the command will be printed below vim's statusbar.

    Real world example with CoffeeScript:

    https://github.com/epeli/vimconfig/commit/4047839c4e1c294ec7e15682f68563a0dbf0ee6d

提交回复
热议问题