6

Is there a function in Vim which will switch to a buffer? For example, if I know that I have the TODO.txt file open in some window in some tab, I’d like to jump to that tab and focus that window. Is that possible?

ib.
  • 26,410
  • 10
  • 77
  • 98
David Wolever
  • 139,281
  • 83
  • 327
  • 490

3 Answers3

7

set swb=useopen,usetabe will set make :sb [number] or :sb [pattern] switch to an open window in whichever tab.

Peter Rincker
  • 41,641
  • 9
  • 70
  • 96
  • Hrm… Either things have changed in 7.3 (I'm on 7.2), or `swb` doesn't quite do what I want. In 7.2, it seems like `swb` is only checked when jumping to errors and using quickfix and stuff. When I've got `set swf=useopen,usetab`, running `:b foo` still replaces the current window with the buffer matching `foo`. – David Wolever Apr 26 '11 at 03:07
  • @David Wolever, your absolutely correct. You should be using `:sb` instead of `:b`. I have corrected the post. – Peter Rincker Apr 26 '11 at 03:22
3

I believe it's :drop filename

YXD
  • 30,245
  • 14
  • 70
  • 111
  • Hhmm… Close, although that requires the full path to the file, which kind of sucks if you've got a bunch of files open (where as, with buffers, you can tab-complete fairly easily). – David Wolever Apr 24 '11 at 18:26
0

I use

 :buf TODO

you need a unique identifiying piece of the buffers filename. You can use tab-completion, though :)

Oh IC, just noted that you want to activate the corresponding tab. Sry

sehe
  • 350,152
  • 45
  • 431
  • 590