假设我并排打开两个缓冲区并将源代码输入缓冲区 1。我想运行编译器(或任何命令行程序)并stdout在缓冲区 2 中查看其输出 ( )。
我如何为stdin这个命令行程序提供当前或特定的缓冲区?如果这是不可能的,我可以将源代码保存到文件中并将其指定为编译器的参数;但无论如何我想在缓冲区 2 中看到输出。
如果你看:h :b:
:[N]b[uffer][!] [+cmd] [N] :b :bu :buf :buffer E86
Edit buffer [N] from the buffer list. If [N] is not given,
the current buffer remains being edited. See :buffer-! for
[!]. This will also edit a buffer that is not in the buffer
list, without setting the 'buflisted' flag.
Also see +cmd.
Run Code Online (Sandbox Code Playgroud)
而对于+cmd:
+cmd [+cmd]
The [+cmd] argument can be used to position the cursor in the newly opened
file, or execute any other command:
+ Start at the last line.
+{num} Start at line {num}.
+/{pat} Start at first line containing {pat}.
+{command} Execute {command} after opening the new file.
{command} is any Ex command.
Run Code Online (Sandbox Code Playgroud)
所以:
:2b +r!date
Run Code Online (Sandbox Code Playgroud)
将打开缓冲区 2,并读入date命令的输出。