我正在尝试在视觉选择上运行 shell 命令,但我不知道如何在选择上而不是在选定的行上运行它,例如:
Selection start here
v
hello
world
^ Ends here
Run Code Online (Sandbox Code Playgroud)
运行以下命令将发送hello\nworld到my_command
:'<,'>!my_command
Run Code Online (Sandbox Code Playgroud)
我怎样才能发送lo\nwor到my_command. \n换行符在哪里
阅读:help '<页面后,我得到了'<应该模拟什么的印象`<:
'< `< To the first line or character of the last selected
Visual area in the current buffer. For block mode it
may also be the last character in the first line (to
be able to define the block). {not in Vi}.
Run Code Online (Sandbox Code Playgroud)
您可以使用键映射来实现类似的效果。
vnoremap <C-s> y:! <C-r>0<Home><right>
Run Code Online (Sandbox Code Playgroud)
这将以Ctrl-S视觉模式进行映射。它复制选定的文本,调用命令行并粘贴选定的文本,然后移动光标在 处输入命令!。