12

I've already seen Switching to a particular tab in VIM.

but I'd like to know whether it's possible to switch to a particular tab thanks to its name, not thanks to its number (which I find not very natural) (with code completion when we type only the first letter of the filename inside the tab).

Community
  • 1
  • 1
ThePhi
  • 2,373
  • 3
  • 28
  • 38

1 Answers1

14

Tab pages don't have names so there is simply no way to switch to a specific tab page by… its name.

The label in the tab widget is the name of the buffer displayed in the focused window in the corresponding tab page. Thus, it could be anything from foo.txt to [No Name] via [Quickfix List] or p/a/t/t/h/to/bar.js, none of which would be of any use. Even foo.txt would not be that useful because of the very nature of buffers which can be displayed in any number of windows in any number of tab pages.

See :help tab-page.

There is a very limited solution, though: :sbuffer is the only "buffer" command that respects the 'switchbuf' option and allows you to switch to a specific buffer where it is displayed instead of in the current window.

:set switchbuf=useopen,usetab
:sb foo.txt

See :help 'switchbuf' and :help :sb.

Anyway, it seems that you are using tab pages as file proxies. This is very bad idea: buffers are the real thing.

Community
  • 1
  • 1
romainl
  • 186,200
  • 21
  • 280
  • 313