无法在 Vim 中的文件之间快速移动
我的 .Zshrc 中有以下内容
. /Users/Masi/bin/Zsh/prompt
我需要运行以下代码才能从 .zshrc 访问该文件
Ctrl-Z
vim ~/bin/Zsh/prompt
我尝试通过首先在可视模式下突出显示路径并运行
:'<,'>!vim
How can you move fast between files in Vim 来执行 相同的操作,但没有成功?
I have the following in my .Zshrc
. /Users/Masi/bin/Zsh/prompt
I need run the following code to access the file from .zshrc
Ctrl-Z
vim ~/bin/Zsh/prompt
I tried to do the same unsuccessfully by first highlighting the path in visual mode and running
:'<,'>!vim
How can you move fast between files in Vim?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您打开了 vim,则可以使用
:e
命令打开文件进行编辑。如果你想在同一个vim会话中同时打开多个文件,你可以使用windows。 您可以使用
Ctrl-W n
打开一个新窗口,然后使用:e
在新窗口中打开文件。 对你来说,找到一个如何使用 Windows 的教程可能比我在这里做一个糟糕的解释工作更好。 不过,它们使用起来并不太困难。另一种选择是为每个文件建立一个单独的 vim 会话,然后使用作业处理根据需要循环遍历它们。 我不熟悉 zsh 语法,但在 bash 中,您可以按 Ctrl-Z 暂停当前正在运行的作业并返回到命令行,然后使用 fg % 恢复作业n 其中 n 是您要恢复的作业编号。 因此,您可以使用这些命令使用 vim 打开文件 1,暂停 vim,使用新的 vim 会话打开文件 2,暂停它,并根据需要来回交替暂停和前景。
希望这可以帮助!
If you have vim open, you can open a file for editing using the
:e <filepath>
command.If you want to have multiple files open simultaneously in the same vim session, you can use windows. You can open a new window with
Ctrl-W n
, then use:e <filepath>
to open the file in the new window. It's probably better for you to find a tutorial for how to use windows than for me to do a poor job explaining how here. They're not too difficult to use though.Another alternative is to have a separate vim session for each file, then to cycle through them as needed using job processing. I'm not familiar with the zsh syntax, but in bash, you can press
Ctrl-Z
to pause the currently running job and return to the command line, and resume a job withfg %n
where n is the job number you want to resume. So you can use these to open file 1 with vim, pause vim, open up file 2 with a new vim session, pause it, and alternate back and forth with pausing and foregrounding as necessary.Hope this helps!
我想您可能正在 Vim 中寻找 gf 命令,该命令会打开在光标位置命名的文件。 此命令在同一窗口中打开文件,替换您之前编辑的任何文件。 如果要打开一个新窗口并将光标所在的文件包含在内,请使用 ^Wf。
另请参阅问题 如何从 Vim 中的 'gf' 返回 有关文件导航的更多信息。
I think you might be looking for the
gf
command in Vim, which opens the file that is named at the cursor position. This command opens the file in the same window, replacing whatever file you were previously editing. If you want to open a new window with the file under the cursor, use ^Wf.See also the question How do you return from 'gf' in Vim for more information on file navigation.