I know CTRLg displays the current file you're working on. Is there a way to modify my .vimrc
such that the filename/path is always displayed?
8 Answers
In your statusline, add a %F
to display the full path:
:help statusline
" Add full file path to your existing statusline
set statusline+=%F
Note, %F
will be the full path. To get a path relative to the working directory, use %f
.
If your statusline is not already visible, you may first need to configure it to be always visible, via laststatus=2
set laststatus=2
See :help laststatus
for what the options mean. Normally, the statusline may be hidden, or hidden unless multiple buffers are open, but I find it extremely useful to have on all the time with customizations like this, well worth giving up one screen line reserve for it.

- 267,341
- 46
- 444
- 390
-
2I certainly prefer your answer to mine, but adding `set statusline+=%F` to my `~/.vimrc` doesn't seem to do what your saying. Although the docs certainly seem to agree with you... – Tim Pote May 07 '12 at 20:41
-
2This had no effect. Apologies if Im missing something simple, do you have any thoughts on that? – zallarak May 07 '12 at 20:42
-
1@TimPote What vim version? Works for me. Maybe your statusline is already pushing it off or limiting width. Try just `:set statusline=%F` without the `+` – Michael Berkowski May 07 '12 at 20:43
-
@zallarak See my comment to Tim. Does your statusline change if you simply do `:set statusline=%F`? Look way over to the right or left to see if the filename is hiding over there in the statusline – Michael Berkowski May 07 '12 at 20:43
-
@Michael version 7.3.353. `:set statusline=%F` does nothing as well. Let me track down my current statusline settings. – Tim Pote May 07 '12 at 20:45
-
2@TimPote Maybe `set laststatus=2` to keep the statusline visible all the time. I forgot I had that on. – Michael Berkowski May 07 '12 at 20:49
-
@Michael Ah, I see. It isn't in the standard line that shows the line/column number, etc. – Tim Pote May 07 '12 at 20:50
-
@TimPote That's the ruler, the statusline is a lot more robust and capable. http://stackoverflow.com/questions/5375240/a-more-useful-statusline-in-vim – Michael Berkowski May 07 '12 at 20:51
-
Sweet. +1 for bringing in the statusline then. – Tim Pote May 07 '12 at 20:58
-
I believe some vim extensions will steal the statusline (e.g. syntastic) for their own use, so using `set title` as in one of the other answers might be better for some people. – AlexMA Sep 27 '16 at 19:34
set ls=2
add this in vimrc, and you will see the file name at the bottom always.

- 1,432
- 22
- 38
-
set modeline didn't do anything for me, what is it suppose to do? (set ls=2 did do something though). How do I man/help to figure this out on my own the next time? Thanks! :) – Charlie Parker Feb 12 '14 at 22:40
-
1`set modeline` is a bit dangerous and has nothing to do with the question. It allows the execution of Vim commands in the 5 beginning/ending lines of a file. It should be turned on only by those who knows why and really want this. (Thats why I -1 this answer) – DrBeco Aug 31 '14 at 03:03
I found 2 ways to display the file path in the Title bar of the gnome-terminal while editing a file with Vim.
The simpler (and better) way: Add the following line to your ~/.vimrc
:
set title
Which will show you at the top:
filename.ext (~/path_to_directory_where_your_file_is/) - VIM
The more complicated way will show you the absolute file path. It's documented in a bit more detail in this blog post I recently wrote.

- 45,805
- 12
- 84
- 81
-
The "set title" will show the file name on the terminal tab. Interesting feature. – duleshi Jun 11 '14 at 09:22
-
Interesting as it is, doesn't answer the question asked. Also you assert it's better - but it might not be. For example if you your vim is open in terminal which is in full screen mode, title isn't visible. Thus downvote. – apprenticeDev May 21 '15 at 23:34
If you are using vim-airline, put in .vimrc
:
let g:airline_section_c = '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
This is a modification of the airline default, changing %f
by %F
.

- 730
- 7
- 16
The only way I found to get the full path of the file I'm working in is: :echo expand('%:p')
. You can re-map ctrl+g if you want, but I personally don't like shifting away from the standards too much. I've mapped F7 like so:
map <F7> <Esc>:echo expand('%:p')<Return>

- 27,191
- 6
- 63
- 65
-
4`:help CTRL-G`, and look two paragraphs down for `CTRL-G` with count. – Stefan Majewsky Aug 14 '12 at 08:17
-
1Thanks, @StefanMajewsky. `1 CTRL-G` shows full file name. I was searching for this option. – Anton Kiselev Sep 23 '13 at 03:04
-
I love u Tim, this is the only way to absolutely show absolute path, even without `~`. – ryancheung Sep 15 '17 at 07:48
I've always used :f
, but the answer and links from @MichaelBerkowski are amazing!
:f
shows the path, line count, modified state, current cursor position, and more...
I didn't know about CTRLG but it appears to be about the same.

- 22,322
- 9
- 59
- 108
The statusline is very powerful and handy I think. Strait out of the box it will display filename, cursor position and some flags. But you want to do the same as me and replace the filename-part with the full path to the file.
So while editing my .vimrc
my statusline could look something like this as default:
.vimrc 26,16 7%
You could view your setting of the statusline with:
:set statusline?
But if you have not made any alterations and no module has changed it it would be empty. But by the examples in the help-section (:help statusline
) you could find that the default is:
:set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
So include this in your .vimrc
and change %f
to %F
. I also added added the filetype flag (%y
) to my statusline since I find it convenient. So my resulting configuration looks like this:
:set statusline=%<%F\ %h%m%r%y%=%-14.(%l,%c%V%)\ %P
And the result would look something like this:
~/.vimrc [vim] 26,16 7%
Good reading:
PS. I run vim 7.3
If you want the path to include resolved symlinks, use the following:
set statusline +=%{resolve(expand('%:p'))}\ %*
To keep the '~' abbreviation for your home directory, include fnamemodify
set statusline +=%{fnamemodify(resolve(expand('%:p')),':~')}\ %*

- 43,590
- 17
- 150
- 159
-
Both of these worked for me in VIM 7.4 using iTerm2 to SSH into Ubuntu 16.04 LTS – nicholsonjf Jul 06 '17 at 19:45