Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to let tab display only file name rather than the full path in vim

Tags:

vim

If the full path of a file is very long, you can't tell which file is in a given tab. so I'm wondering is there is a way let the tab only display the file name rather than the full path of the file, might be convenient in some case.

like image 931
Haiyuan Zhang Avatar asked Mar 18 '10 10:03

Haiyuan Zhang


People also ask

How do I see the filename in Vim?

If all that is wanted is to display the name of the current file, type Ctrl-G (or press 1 then Ctrl-G for the full path). When using @% , the name is displayed relative to the current directory. In insert mode, type Ctrl-R then % to insert the name of the current file.

How do I use tabs in Vim?

To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs. To open multiple files in tabs: $ vim -p source.

What is Tabline Vim?

Vem Tabline is a lightweight Vim/Neovim plugin to display your tabs and buffers at the top of your screen using the editor's tabline. Vem tabline shows the list of open buffers to the left of the top line of the screen and tabs as numbered workspaces to the right.


2 Answers

Try

:set guitablabel=%t

For format of possible options see

:help 'statusline'

like image 173
Habi Avatar answered Oct 11 '22 22:10

Habi


I have the following in my vimrc:

set guitablabel=\[%N\]\ %t\ %M  

which outputs: [Number] Filename and + sign if a file is modified ([4] foo.html +). Number is very useful to immediate switch to the chosen tab with command [Number]gt (4gt if I want to jump to the file in the tab 4)

like image 41
larsen1 Avatar answered Oct 11 '22 21:10

larsen1