In Vim, how can I capture the path of the current file?
I know that the % register contains the name of the current file, but I want the path, so I can do something like
:w **bar.txt... to "Save As" a new file, with ** representing the current file's path so that the new file will go in the same folder.
1 Answer
Answered at
% is the actual file
%:p:his the dirname of the file
%:pis the full path of the file. Use what you prefer.
In order to save files, just
:w %:p:h/something