您更喜欢如何在 Vim 中的缓冲区之间切换?
我尝试过 MiniBufExplorer,但我通常会看到几个窗口显示或完全关闭它。 我想要的是类似 LustyJuggler 的增量搜索方式,我在 Emacs 中的缓冲区之间切换。 肯定有这样的脚本吗?
I've tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I'd like is something like LustyJuggler with incremental search, the way I switch between buffers in Emacs. Surely there is a script like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
我曾经使用选项卡和多个 gvim 实例的组合,将相关文件组保留为每个实例中的选项卡。 只要我在一个实例中没有出现太多选项卡,选项卡栏就会一目了然地显示您正在编辑的每个文件的名称。
然后我读了 Jamis Buck 的一篇文章,介绍了他如何从 TextMate 切换到 回到 vim,并学习了一些很棒的技巧:
fuzzyfinder
的工作方式,使其更像TextMate
中的类似功能(据我所知,区别在于它匹配文件名中的任何位置,而不是仅从开头匹配)。 观看此视频以了解其实际效果。现在我只有一个
gvim
实例,将其最大化,并将其拆分为多个窗口,这样我就可以同时查看多个文件。 我将 Ctrl+F 绑定到fuzzyfinder\_textmate
,所以现在如果我输入(比如说)Ctrl+Fmod/usob
它打开app/models/user\_observer.rb
。 我几乎不再理会标签了。更新 2010/08/07
尽管
fuzzyfinder\_textmate
仍然很棒,正如 Casey 在评论中指出的那样,但它已不再维护。 另外,在处理大型项目(大量目录或文件)时,它(和/或 fuzzyfinder.vim )会变得有点慢且不稳定,所以我一直在寻找替代方案。幸运的是,似乎有一个非常好的替代方案,即 Wincent Colaiuta 的 Command-T 插件。 这与 fuzzyfinder\_textmate 的行为非常相似(如果不是稍微好一点的话),但速度明显更快; 它还具有很好的功能,例如能够以拆分或垂直拆分方式打开找到的文件。 感谢(并投票!)大卫·里弗斯指出了这一点。
I used to use a combination of tabs and multiple
gvim
instances, keeping groups of related files as tabs in each instance. So long as I didn't end up with too many tabs in one instance, the tab bar shows you the name of each file you're editing at a glance.Then I read a post by Jamis Buck on how he switched from TextMate back to vim, and learned some great tricks:
fuzzyfinder
works to behave more like a similar feature inTextMate
(as far as I can tell, the difference is that it matches anywhere in the filename instead of only from the start). Watch this video to see it in action.Now I just have one
gvim
instance, maximised, and split it into multiple windows so I can see several files at once. I bound Ctrl+F tofuzzyfinder\_textmate
, so now if I type (say) Ctrl+Fmod/usob
it opens upapp/models/user\_observer.rb
. I almost never bother with tabs any more.Update 2010/08/07
While
fuzzyfinder\_textmate
remains awesome, as Casey points out in the comments, it's no longer maintained. Also, it (and/orfuzzyfinder.vim
) gets a bit slow and unstable when working with large projects (lots of directories or files), so I've been looking for an alternative.Fortunately, there seems to be a very nice alternative in the form of Wincent Colaiuta's Command-T plugin. This has very similar (if not slightly better) behaviour to
fuzzyfinder\_textmate
, but is noticeably faster; it also has nice features like being able to open the found file in a split or vertical split. Thanks (and upvotes!) to David Rivers for pointing to it.我使用基础知识 - '
:ls
' + ':bn
'/':bp
' + ':b
'I use the basics - '
:ls
' + ':bn
'/':bp
' + ':b <part-of-name>
'我喜欢“ctrl-w s”和“ctlr-w v”来分割窗口。 然后我按住 ctrl 映射移动键(h、j、k、l)以在分割窗口之间移动:
必须将手移到箭头键上很烦人。
接下来,我设置了 ctlr-tab 在当前窗口中的缓冲区之间进行切换(就像许多其他环境一样):
在过去的几年里,这些对我来说非常有效,尽管 vim 总是有比你知道的更多的秘密。
I like "ctrl-w s" and "ctlr-w v" to split the window. Then I map the movement keys (h, j, k, l) with ctrl held down to move between the split windows:
Having to move my hand over to the arrow keys is annoying.
Next, I set up ctlr-tab to switch between buffers in the current window (like a lot of other environments):
These have worked pretty well for me over the last several years although vim always has more secrets than you can know.
我已经使用 Wincent Colaiuta 的 Command-T vim 插件 几个月了。 Wincent 用 C 语言编写了其中需要快速的部分,我必须说确实如此! 而且,我认为它的文件模式匹配逻辑甚至比 Textmate 的 Command-T 更好。 查看
更轻松的缓冲区切换包含许多有用的提示。 我已将以下内容调整到我的 .vimrc 中,它会自动完成缓冲区名称,将最有用的缓冲区切换命令映射到我的中。 和左侧主行键,并在状态行中显示当前缓冲区编号:
我还使用 MiniBufExplorer,它在其自己的水平分割顶部提供每个列出的缓冲区的紧凑列表。
I have been using Wincent Colaiuta's Command-T vim plugin for a couple months now. Wincent wrote the parts of it that need to be fast in C, and I must say that it is! And, I think its file pattern matching logic is even better than Textmate's Command-T. Check out the screencast.
Easier buffer switching contains many useful tips. I have adapted the following to my .vimrc, which does buffer-name auto-completion, maps the most useful buffer-switching commands to my <Leader> and left-side home row keys, and shows the current buffer number in the status line:
I also use MiniBufExplorer, which provides a compact listing of each listed buffer in its own horizontal split up top.
没有人提到好插件 ctrlp.vim。 使用此插件,您可以按名称搜索缓冲区。
and nobody mentioned nice plugin ctrlp.vim. Using this plugin you can search buffer by name.
我使用
CTRL-J 作为下一个缓冲区
CTRL-K 作为上一个缓冲区
CTRL -L 表示下一个选项卡
CTRL-H 表示上一个选项卡
这是
.vimrc
配置:请参阅 http://syskall.com/my-biggest-vim-productivity-boost/
I use
CTRL-J for next buffer
CTRL-K for previous buffer
CTRL-L for next tab
CTRL-H for previous tab
Here is the
.vimrc
configuration:See http://syskall.com/my-biggest-vim-productivity-boost/
我最近变得更加简约。
要循环缓冲区,我使用未受损的 ]b 和 [b: https://github.com/tpope/vim-unimpaired
要直接跳转到打开的缓冲区,只需使用 Vim 的制表符补全功能 :b 即可。 几个字母足以通过一两个选项卡到达任何打开的缓冲区。
与打开缓冲区类似,我使用 :e 以及相对路径和制表符完成。
我偶尔也会使用 :ls 来查看我打开了哪些缓冲区(并检查它们的修改状态)。
为了摆脱缓冲区,我使用 :bw 来擦除缓冲区。 我通常会进行临时分割并更改缓冲区以保留我的布局,但因为 :bw 也会关闭活动窗口。
我尝试过的所有 minibuf 东西最终都让我烦恼,我不希望一些智能匹配的东西为我打开随机文件。 如果我确实需要浏览某些内容,我会使用 NERDtree (:e .)。
IDK,最近我也放弃了 Yankring(因为它搞砸了 xp)并开始使用寄存器,并且我最近决定 f/t 运动是有史以来最伟大的事情...
I've recently gone more minimalistic.
To cycle buffers I use ]b and [b from unimpaired: https://github.com/tpope/vim-unimpaired
To jump straight to an open buffer just use Vim's tab completion with :b. A few letters is enough to get to any open buffer with a tab or two.
Similarly to open buffers I use :e with relative paths and tab complete.
I also use :ls occasionally to see what buffers I have open (and to check their modified status).
To get rid of a buffer I use :bw to wipe the buffer. I usually make a temporary split and change buffers to preserve my layout though since :bw also closes the active window.
All the minibuf things I tried just ended up annoying me, and I don't want some smart-matching thing opening random files for me. If I really need to browse for something I use NERDtree (:e .).
IDK, Lately I also dropped Yankring (because it screws up xp) and started using registers, and I recently decided the f/t movements are the greatest thing ever...
要列出缓冲区并在缓冲区之间切换,我使用:
要在缓冲区之间切换:
To list and switch between buffers I use:
To switch between buffers:
优秀的 Buffer Explorer,已经变得如此强大了我发现自己希望可以在其他应用程序中使用它。 我发现在主动编辑两个以上文件时它的速度非常快。
The excellent Buffer Explorer, the be has gotten to be such strong muscle memory that I find myself wishing I could use it in other applications. I find it to be extremely fast when actively editing more than two files.
我花了相当长的时间来构建我的 .vimrc 来处理这个我已经从事了四年的 HTML::Mason 项目,所以我有一个奇怪的选项卡和分割窗口的组合。 为了您的观看享受:
I've spent quite a while building my .vimrc to work with this HTML::Mason project I've been on for four years, so I have an odd mix of tabs and split windows. For your viewing enjoyment:
我使用 tselectbuffer。 它非常快,并且与 bufexplorer 不同,它不会占用窗口空间。 它还有增量搜索。我尝试了 minibufexplorer,发现缓冲区中的导航有点困难。
I use tselectbuffer. It's really fast and unlike bufexplorer doesn't take space in your window. It also has a incremental search.I tried minibufexplorer and I found the navigation in the buffer a bit difficult.
我已将
和
映射到:bp
和:bn
,尽管我承认我不使用它,因为文件数量大于 10。然后我将
和
映射到 Gnome Terminal 的上一个和下一个选项卡,我通常为我从事的 4 个不同项目中的每一个运行 4 个 vim 实例。 我仍然非常希望下一个和上一个缓冲区能够进入我一直在处理的缓冲区的历史记录,而不是缓冲区列表中的顺序。I have mapped
<S-J>
and<S-K>
to:bp
and:bn
, although I admit I don't use it as the number of files is greater than 10. I have then mapped<C-J>
and<C-K>
to Gnome Terminal's previous and next tabs, and I usually run 4 instances of vim for each of the 4 different projects I work on. I still really wish next and previous buffer would go to the history of buffers I have been working on, and not the order int he buffer list.我使用 tselectbuffer。 它非常快,并且与 bufexplorer 不同,它不会占用窗口空间。 它还有增量搜索。我尝试了 minibufexplorer,发现缓冲区中的导航有点困难。
I use tselectbuffer. It's really fast and unlike bufexplorer doesn't take space in your window. It also has a incremental search.I tried minibufexplorer and I found the navigation in the buffer a bit difficult.
我使用简单的 :vsplit 与 ^W+w/^W+r 和 :tabnew 与 Ctrl+Alt+PgUp/PgDown 组合键。
i use simple :vsplit with ^W+w/^W+r and :tabnew with Ctrl+Alt+PgUp/PgDown key combinations.
当 Vim 会话中打开多个缓冲区时,跟踪缓冲区及其各自的缓冲区编号可能会变得困难。 如果是这种情况,使用简单的映射可以更轻松地切换到不同的文件:
vim.wikia.com
When there are several buffers open in a Vim session, it can become difficult to keep track of the buffers and their respective buffer numbers. If this is the case, switching to a different file can be made easier using a simple map:
vim.wikia.com