vim Tips and tricks to boost productivity How to know the directory and/or the path of the file you are editing


Example

To know the path of the directory your file is in you can use:

Esc to enter command mode

:pwd

This will print the path to the directory at the bottom of the editor, like this

I'm a ninja
~
~
~
~
~
/home/ubuntu/myfolder                                                1,5         All

Now, if you want to know the file name you are editing relatively to the vim working directory, you can use:

Esc to enter command mode CTRLG

I'm a ninja
~
~
~
~
~
"myfile"[Modified][New file] 1 line --100%--                         1,5         All

Finally to get the absolute path to the file you are editing, use

Esc to enter command mode,

1 and then CTRLG

I'm a ninja
~
~
~
~
~
"~/myfolder/myfile"[Modified][New file] 1 line --100%--              1,5         All