How to display the file name that I am working on in VI as the tab name

PROBLEM DESCRIPTION


This article explains how you can display the file name that you are working on in VI as the tab name in Xshell



RESOLUTION


VI editor includes a feature that allows users to customize the terminal title. You can use this feature with the "Show Terminal Title" feature in Xshell to display the file name that you are working on in VI on Xshell tab name.

To do this, follow the instruction below:
  1. Set terminal type to xterm in Xshell
    1. Open the Session Properties dialog box.
    2. Click on the Terminal menu.
    3. Select xterm from the terminal type list

  2. Open $HOME/.vimrc and add the following lines:

    auto BufEnter * let &titlestring = hostname() . " - " . expand("%:p")
    set title
  3. Right click on the Xshell tab and select the Show Terminal Title menu.

For more information on VIM and how to set the terminal title, you can refer to the VIM manual.