How to display the name of file which I am currently editing with vim on terminal title?
You must to have/create a file named .vimrc
in your home directory with the following code inside:
let &titlestring = $USER . "@" . hostname() . " " . expand("%:p")
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
Source: gnome-terminal does not allow changing the title
The current (accepted) answer doesn't work if you switch files/buffers within one of your vim sessions. The title won't get updated.
The following is enough to have automatically updated titles in gnome-terminal also when you switch files by using :e foo.txt
, :b0
, :b#
, etc.
Just place this in your ~/.vimrc
file:
autocmd BufEnter * let &titlestring = ' ' . expand("%:t")
set title
System: Ubuntu 14.10, vim 7.4.273, gnome-terminal 3.6.2-0ubunt.
Simply add
set title
to your ~/.vimrc
.
Example title: testfile (~/Documents) - VIM