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?
By default, Vim only shows the filename of the currently open file in the status line and the command line below it. Sometimes, you might want to view the full path of the file. To do that, press 1 followed by Ctrl-G . The full path of the file is displayed in the command line at the bottom.
The answer is the pwd command, which stands for print working directory. The word print in print working directory means “print to the screen,” not “send to printer.” The pwd command displays the full, absolute path of the current, or working, directory.
Pressing 1 followed by Ctrl + G shows the full path of the current file.
You can change the working directory with :cd path/to/new/directory . Or you can enter the full path to the location where you want to save the file with the write command, e.g., :w /var/www/filename .
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.
set ls=2
add this in vimrc, and you will see the file name at the bottom always.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With