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

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

    Another answer:

    function Pastebin() range
        let savedreg=@"
        silent execute a:firstline.",".a:lastline."yank"
        python import vim, subprocess
        python p=subprocess.Popen(["pastebin"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
        python p.stdin.write(vim.eval('@"'))
        let @"=savedreg
        python p.stdin.close()
        python retstatus=p.poll()
        python print p.stdout.read()
    endfunction
    

    Requires python support. Use it just like matias' function.

提交回复
热议问题