Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

editor - How do you prefer to switch between buffers in Vim?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  • Ctrl-w s and Ctrl-w v to split the current window
  • Ctrl-6 to switch back and forth between two buffers in the same window.
  • the awesome fuzzyfinder.vim which gives you autocompleting search of files in your current directory or of buffers you currently have open
  • Jamis' own fuzzy_file_finder and fuzzyfinder_textmate, which slightly modify how fuzzyfinder works to behave more like a similar feature in TextMate (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 to fuzzyfinder_textmate, so now if I type (say) Ctrl-F mod/usob it opens up app/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/or fuzzyfinder.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...