我是UNIX新手。我正在使用VI编辑器编写C程序。如果我像下面这样同时打开多个文件:
vi *.c
我只能编辑第一个文件。如果我按“:wq”,它会显示还有“6个文件要编辑”。
如何在这些文件之间切换?下一个文件::n
上一个文件::p
,:N
或:prev
取决于使用的vi实现。
这是一个典型的备忘单,其中有一个关于“文件”主题的部分。
对于Linux Red-Hat VI版本7.2.411,使用:n和:N来切换到下一个和上一个。
:e File
Edits the specified file. If you are using this subcommand
from the ex editor, you do not need to type the : (colon).
:e!
Re-edits the current file and discards all changes.
:e + File
Edits the specified file starting at the end.
:e + Number File
Edits the specified file starting at the specified line number.
:e #
Edits the alternate file. The alternate file is usually the
previous file name before accessing another file with a
:e command. However, if changes are pending on the current
file when a new file is called, the new file becomes the
alternate file. This subcommand is the same as the Ctrl-A
subcommand.
Ctrl-G
Shows the current file name, current line number, number of
lines in the file, and percentage of the way through the
file where the cursor is located.
例如:
~# vi foo*.c
:n
Next File
:N
Last File
:b1
:first
First File
:last
Last File
:b#
`#` switch to buffer `N` file
:e#
其中 # 为文件号码