以下命令成功启动vim,该vim从标准输入中读取编辑缓冲区。
echo hi | vim -
但这是行不通的。
echo hi | vim --remote-tab-silent -
运行以上命令时,会出现以下警告,并且vim退出。
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
在第二种情况下,为什么不从标准输入中读取?
vim的帮助消息似乎表明它应该起作用了?
$ vim -h | head
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07)
usage: vim [arguments] [file ..] edit specified file(s)
or: vim [arguments] - read text from stdin
or: vim [arguments] -t tag edit file where tag is defined
or: vim [arguments] -q [errorfile] edit file with first error
Arguments:
-- Only file names after this
-g Run using GUI (like "gvim")
$ vim -h | grep remote
--remote <files> Edit <files> in a Vim server if possible
--remote-silent <files> Same, don't complain if there is no server
--remote-wait <files> As --remote but wait for files to have been edited
--remote-wait-silent <files> Same, don't complain if there is no server
--remote-tab[-wait][-silent] <files> As --remote but use tab page per file
--remote-send <keys> Send <keys> to a Vim server and exit
--remote-expr <expr> Evaluate <expr> in a Vim server and print result
使用时,不能从stdin中进行编辑--remote
。
:h --remote
--remote [+{cmd}] {file} ...
Open the file list in a remote Vim. When
there is no Vim server, execute locally.
There is one optional init command: +{cmd}.
This must be an Ex command that can be
followed by "|".
The rest of the command line is taken as the
file list. Thus any non-file arguments must
come before this.
You cannot edit stdin this way |--|.
The remote Vim is raised. If you don't want
this use >
vim --remote-send "<C-\><C-N>:n filename<CR>"
--remote-silent [+{cmd}] {file} ...
As above, but don't complain if there is no
server and the file is edited locally.
--remote-tab-silent Like --remote-silent but open each file in a
new tabpage.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句