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?
Asked
Active
Viewed 837 times
7

ib.
- 27,830
- 11
- 80
- 100

David Wolever
- 148,955
- 89
- 346
- 502
3 Answers
8
set swb=useopen,usetabe
will set make :sb [number]
or :sb [pattern]
switch to an open window in whichever tab.

Peter Rincker
- 43,539
- 9
- 74
- 101
-
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
- 31,741
- 15
- 75
- 115
-
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
- 374,641
- 47
- 450
- 633