如何使用VI编辑器在UNIX中的多个文件之间切换?
我是 UNIX 新手。我正在使用 VI 编辑器进行 C 编程。 如果我使用 VI 编辑器一次打开多个文件,
vi *.c
我只能编辑第一个文件。如果我按“:wq”,它会显示有:“还有 6 个要编辑的文件”
如何在这些文件之间切换?
I'm new to UNIX. I am using VI editor to code for C programming.
If I open multiple files at a time using VI editor like,
vi *.c
I can edit the first file only. If I press ":wq", it shows me that there are: "6 more files to edit"
How can I switch between those files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
下一个文件:
:n
上一个文件:
:p
、:N
或:prev
取决于您使用的 vi 实现正在使用。这是一个典型的备忘单,其中有一个关于该主题的“文件”部分。
http://www.lagmonster.org/docs/vi2.html
Next file:
:n
Previous file:
:p
,:N
or:prev
depending on which vi implementation you're using.Here's a typical cheat sheet which has a section "Files" on this topic.
http://www.lagmonster.org/docs/vi2.html
对于 Linux Red-Hat VI 版本 7.2.411,使用 :n 和 :N 切换下一个和上一个。
For Linux Red-Hat VI version 7.2.411 use :n and :N to switch next and previous.
AIX 的 vi 有它自己的命令;我花了一段时间才找到这些信息,因为这个问题的答案还没有,所以我会添加这个答案。
:p
、:N
和:prev
都无法转到上一个文件,您需要使用 < 的变体之一code>:n --- 命令。移动到下一个文件的
:n
是相同的使用
:n file_name
移动到某个文件(也可以用这种方式打开新文件)(要转到前一个文件,只需使用前一个文件的名称即可使用
:n 文件名列表
定义要编辑的新文件列表(在本例中,文件list
,of
、文件
以及运行:n 文件名列表
后,将使用:n
连续打开names
手册页中的其他有用结果
AIX's vi has it's own commands; it took me a while to find this information because the answers in this question didn't have it already, so I'll add this answer.
Neither
:p
,:N
, nor:prev
work to go to the previous file, you need to use one of the variations of the:n ---
command.The
:n
for moving to the next file is the sameUse
:n file_name
to move to a certain file (Can open new files this way too) (To go to the previous file, just do this with the previous file's nameUse
:n list of file names
to define a new list of files to edit (In this case, the fileslist
,of
,file
, andnames
would be opened in series using:n
after running:n list of file names
Other useful results from the man pages
再加上两个,:first & :last
ig:
~# vi foo*.c
:n
:N
:b1
:first
:last
:b
#
plus two more, :first & :last
ig:
~# vi foo*.c
:n
:N
:b1
:first
:last
:b
#
:b# 正在 vi 编辑器中打开特定文件,当打开多个文件时,# 表示此处的数字
:b# is working in vi editor to open particular file, when multiple files are opened, # means numbers here
:e#
其中 # 是文件编号:e#
where # is the file number