When I have more one one file open in vim (using split-screen), each commandstatus line (the last line in the window) looks like this:

filename.txt                           73,1            4%

That's the filename on the left, with the ruler position and percentage through the file on the right (via :set ruler).

However, when I only have one buffer open, the status line looks like:

                                       73,1            4%

How can I show the filename in all circumstances, even when there is only one file open?


That's the status line (:help status-line). To enable it when you only have one window, add to your .vimrc:

set laststatus=2
  • Ah, I thought it was called the command line because that's the reference that came up with :help ruler -- the compiler option cmdline_info needs to be enabled. Question text edited. And thank you! – Ether Sep 27 '10 at 17:30

Another option is to use :set title which sets filename with path in title bar of your console window. The title changes automatically when the filename changes. To enable it permanently add it to your .vimrc


I actually think the very bottom line in vim is called "ruler", since it's enabled by ":set ruler".

The format of the ruler could be customized, following the same syntax of "statusline", just as the vim help page says:

Vim help page for "rulerformat"

At last, here is a good tutorial to the vim "statusline", including adding a file name into it: Learn Vimscript the Hard Way -- Status Lines

  • and how I let vim show the buffer filename in rulerformat ? – Sérgio Jul 22 '20 at 9:54
  • @Sérgio :set laststatus=2 will do the trick for you. – Samuel Li Jul 23 '20 at 17:29
  • :set laststatus=2 show status one line above of status line, I prefer :set title – Sérgio Jul 23 '20 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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