Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the current filename in each split window's status line in Vim?

I have a global statusline set, but it would be useful if each split window had the current filename in its own statusline.

like image 393
Eno Avatar asked Aug 14 '15 22:08

Eno


People also ask

How do I see the filename in Vim?

If all that is wanted is to display the name of the current file, type Ctrl-G (or press 1 then Ctrl-G for the full path). When using @% , the name is displayed relative to the current directory. In insert mode, type Ctrl-R then % to insert the name of the current file.

What is status line Vim?

The statusline is intended to give you information about the status of a buffer with the default statusline including the path, permissions, line and a percentage representation of where you are in the file.


1 Answers

OK, the default setting is empty so I added the following setting for stock console vim that seems to play nice with the NERDTree and Syntastic plugins:

" [buffer number] followed by filename:
set statusline=[%n]\ %t
" for Syntastic messages:
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" show line#:column# on the right hand side
set statusline+=%=%l:%c
like image 126
Eno Avatar answered Nov 02 '22 11:11

Eno