0

Is there any way to do something similar to pinning a browser tab with Vim tabs? ie:

  • Fix position on the left
  • Minimise its size
  • Prevent it being closed

2 Answers 2

0

No, there isn't, but you could create something to that effect.

To most faithfully reproduce the pinned tabs behavior of web browsers, you'd have to override all the tab-related commands (like gt, and :tabnext) with custom mappings and custom commands (potentially using cmdalias.vim - Create aliases for Vim commands to override the lowercase original Ex commands). But that's rather involved, and still wouldn't cover any tab modification done my other mappings or plugins.

Alternatively, you could periodically (e.g. when switching windows) record the layout of all tabs (i.e. what buffers they contain), and use that to easily restore an accidentally closed tab (if that's your main concern). After all, the buffers are still available in Vim after a tab has been closed.

Summary

While there's no easy and simple corresponding feature in Vim, if you deeply analyze what your real underlying use case is, a solution can be found. Note that in the eyes of many Vim uses, extensive use of tabs is not recommended. I personally only use a few at a time to segregate different projects / workspaces within one Vim instance.

1

You could use a custom 'tabline' setting, to set the size/content of any of the tab labels. That would allow you to minimize the size.

Vim doesn't ever really move tabs around on its own, so just a :tabmove 0 should put it on the left. If you want, on a TabEnter autocmd, you could check if there are special tabs to the right of the tab, and if this tab is not special, move it rightward until there are no more special ones. Mark special tabs with a t: scoped variable, e.g. :let t:pinned=1.

I don't think there's a way to prevent it being closed, however you could use commands like :tabdo if !exists('t:pinned') | tabclose | endif to close all unpinned tabs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .