将输入和输出重定向到缓冲区或从缓冲区重定向

时间:2018-10-12 19:57:49

标签: shell vim command buffer neovim

是否可以将 shell 命令的输入和输出重定向到vim buffer 或从vim重定向?

预期的行为类似于Emacs shell-command-on-region,用于输入并将输出重定向到emacs一样的缓冲区。输入和输出缓冲区不相同。

1 个答案:

答案 0 :(得分:0)

基于shell-command-on-region中的this description

  

M-| cmd <RET>

     

以区域内容作为输入运行shell命令 cmd ; (可选)用输出(shell-command-on-region)替换区域。

以选定的行作为输入来运行命令的内置方法是:help :w_c

:[range]w[rite] [++opt] !{cmd}
            Execute {cmd} with [range] lines as standard input
            (note the space in front of the '!'). [...]

,用命令输入替换选择的内置方法是:help !

:{range}![!]{filter} [!][arg]               *:range!*
            Filter {range} lines through the external program
            {filter}. [...]

这两种方法都有一些替代方法,阅读帮助部分时不要害怕滚动。

enter image description here

相关问题