Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vi / vim - how to set the tab label/title length to a fixed size in chars

Tags:

vim

vi

tabs

As I open new tabs in vi/vim(7.2), if the opened files are in different paths the tab title displays the complete path and hogs the screen real estate so the other tabs are not visible. This means I can't use my mouse to click to the tab I want but have to resort to : & keyboard commands to move between tabs.

Is there any way I can restrict the tab titles to a max 'size/length', so I only get to see say the last 12 characters of a file in a distant relative path ?

like image 674
molicule Avatar asked Jan 28 '09 17:01

molicule


2 Answers

You can do this pretty nicely for gvim with the setting 'guitablabel'.

Here's an excerpt from my .gvimrc, which modifies the default to only show up to 12 characters of the filename, but keeps the '+' for modified buffers. The tooltip is left unmodified, so you can get the full path from that or by pressing Ctrl-G in command mode.

if version >= 700
    "set showtabline to show when more than one tab
    set showtabline=1
    "set tab labels to show at most 12 characters
    set guitablabel=%-0.12t%M
endif

" don't show the toolbar in the GUI (only the menu)
set guioptions-=T

" don't show tear-off menus
set guioptions-=t
like image 113
werkshy Avatar answered Oct 04 '22 12:10

werkshy


In reply to my own question:

After reading Chad Birch above and googling for setting-tabline I found the TabLineSet plugin that does the trick, and some of script explanations here

like image 24
molicule Avatar answered Oct 04 '22 13:10

molicule