Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often have several files open in vim, each in a different tab. I have to remember which tab has which file open. Is there a way to show this in the tab titles?

share|improve this question
vim supports tabs (both in the GUI and on the command line), so you do not need to use tabs from gnome-terminal. See :help tabpage. – Benjamin Bannier Jul 3 '10 at 23:26
@honk: Thanks, that's pretty neat! I think I'm going to stick with gnome-terminal tabs, so that I can use alt + [tab number] to switch between them. Or is there a way to do this in vim, too? – Matthew Pirocchi Jul 4 '10 at 1:00
CTRL-PgUp/gt and CTRL-PgDown/gT for switching to next/previous tab, and also e.g. 2gt to go to tab 2. Not sure if the CTRL part is default or depends on the terminal setup. – Benjamin Bannier Jul 4 '10 at 2:12
@honk: gnome-terminal steals CTRL-PgUp/PgDown when multiple terminal tabs are open (it works when vim is the only one). 2gt works, but neither option is as convenient for ant + [tab number] anyway. Thanks for the tip, though, I'll remember it if I'm ever stuck using a terminal without tabs. – Matthew Pirocchi Jul 4 '10 at 18:31
up vote 4 down vote accepted


Add this to your .vimrc:

let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
if &term == "screen"
  set t_ts=^[k
  set t_fs=^[\
if &term == "screen" || &term == "xterm"
  set title
share|improve this answer
:set title is enough for gnome-terminal. – Benjamin Bannier Jul 3 '10 at 23:25
For anyone curious: To make the title just the filename, change the first line to let &titlestring = expand("%:t"). – Matthew Pirocchi Jul 4 '10 at 23:45
:set title is enough for terminator too - I added this to the .vimrc – Vitaly Zdanevich Mar 7 at 8:24

More simple way for gnome-terminal, write below in your vimrc :

set title
autocmd BufRead * let &titlestring = expand("%:p")

show only filepath in title

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.