Display name of the current file in vim?

How do you display the filename of the file you are working on in vim?


Solution 1:

:f (:file) will do same as <C-G>. :f! will give a untruncated version, if applicable.

Solution 2:

ctrl+g will do it.

Also, I like to have:

set statusline="%f%m%r%h%w [%Y] [0x%02.2B]%< %F%=%4v,%4l %3p%% of %L"

Which produces:

foo.c [C] [0x23]<code/foo.c   1,   1   2% of 50

Also, as someone mentioned (but now deleted) % will be replaced with the current filename. For example:

:!echo "current file: %"
current file: foo.c
Press ENTER or type command to continue