跳回之前在 Vim 中打开的文件
在使用 Vim 时,我有时会想查看函数定义或结构定义,因此我将使用 C-]
跳转到它。但是,我遇到了一些问题。首先,我不知道如何轻松地跳回来。看来我之前所在的文件已关闭,现在我正在新的文件中。有没有办法跳回来,或者保留一堆打开的文件供我弹回或其他什么?
我注意到的另一件事是,当我对当前文件进行更改时,我需要保存它,因为就像刚才提到的那样,我当前的文件在下一个文件打开之前被关闭。
有时我想立即查看当前的代码和标题。有没有办法在拆分中打开标签定义?
While using Vim I'll sometimes want to look at a function definition or a struct definition, so I'll use C-]
to jump to it. However, there are a few problems I run into. First off, I don't know how to jump back easily. It appears the previous file I was in closes and I'm now in the new one. Is there a way to jump back, or keep a stack of open files that I can pop back to or something?
Another thing I've noticed that when I have a change in the current file I need to save it because, like a mentioned a moment ago, my current file is being closed before the next one opens.
And sometimes I want to view my current code and my header at once. Is there a way open the tag definition in a split?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加
到你的 vimrc.它将允许您切换文件而不保存它们。我认为这是“必须有”的选择之一。
使用 C-o 跳转回跳转列表中自动保存的先前位置。
Add
to you vimrc. It'll allow you switch files without saving them. I think this is one of 'must have' options.
Use C-o to jump back to previous locations which were autosaved in a jumplist.
要从 C-] 跳回,请使用 CT。
:tags
命令显示当前堆栈。设置
autowrite
选项可在跳转到新文件之前自动保存您正在执行的操作。使用 CW C-] 在新窗口中打开标签。
最后,
:help Tags
是帮助中解释所有这些以及更多内容的部分。To jump back from C-], use C-T. The
:tags
command shows the current stack.Set the
autowrite
option to automatically save what you're doing before jumping to a new file.Use C-W C-] to open the tag in a new window.
Finally,
:help tags
is the section in help that explains all this and more.另一个方便的有用功能是大写标记。这些标记不是缓冲区本地的,可用于跨文件跳转到它们。如果您在开始漫长而艰巨的跳跃任务之前使用 mA 命令将该行标记为“A”,那么您最终可以通过键入“A”或“A”快速返回到原始位置。
Another useful feature that comes handy is the uppercase marks. These marks are not local to a buffer and can be used to jump to them from across files. If you mark the line as say "A" using mA command before starting a long and arduous jumping around task, you can finally return back to the original position quickly by typing 'A or `A.
您可能需要考虑使用一些 vim 扩展来使这变得更加简单。
lusty-juggler 和 lusty-explorer
http://www.vim.org/scripts /script.php?script_id=2050
http://www.vim.org/scripts/script.php?script_id= 1890
这些要求 vim 是用 +ruby 构建的。
它们对于留在 vim 中并在文件之间跳转非常有用。
You might want to consider using a few vim extensions that make this even simpler.
lusty-juggler and lusty-explorer
http://www.vim.org/scripts/script.php?script_id=2050
http://www.vim.org/scripts/script.php?script_id=1890
These require that vim was built with +ruby.
They're very useful for staying in vim and jumping between files.