vimtricks.wiki Concise Vim tricks, one at a time.

How do I display the current filename in the terminal window title bar while editing in Vim?

Answer

:set title

Explanation

Enabling title tells Vim to update the terminal window's title bar with information about the current file. This is particularly useful when running multiple terminal windows or tmux panes — you can see at a glance which file each Vim session is editing without switching focus. For full control over the format, pair title with titlestring.

How it works

  • :set title — enables terminal title updates (disabled by default)
  • :set titlestring=... — customizes the title format; supports the same printf-style specifiers as statusline
    • %t — filename only (tail of path)
    • %F — full absolute path
    • %m — modified flag ([+] when buffer has unsaved changes)
    • %r — read-only flag
  • Vim automatically restores the original terminal title when you exit

Example

A practical setup for ~/.vimrc:

set title
set titlestring=%<%F%m\ —\ VIM

This produces a terminal title like:

/home/user/project/src/main.go [+] — VIM

For a minimal title showing just the filename:

set title
" Default: Vim uses "filename (/path) - VIM"

Tips

  • The %< specifier truncates the title from the left if it is too long — useful for deep paths
  • In tmux, Vim's title propagates to the pane title if your ~/.tmux.conf contains set-option -g set-titles on
  • set titleold= controls what title Vim restores on exit (default: "Thanks for flying Vim")
  • In multiplexers like tmux or screen, combining set title with a descriptive titlestring gives you an always-visible file indicator across all panes

Next

How do I configure Vim's :grep command to use ripgrep for faster project-wide searching?