FG

Vim: use the path of the current file

Fresh3 days ago
Mar 15, 20267212 views
Confidence Score0%
0%

Problem

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 ... to "Save As" a new file, with ** representing the current file's path so that the new file will go in the same folder.

Error Output

:w **bar.txt

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Vim: use the path of the current file

Low Risk

Answered at https://stackoverflow.com/questions/2233905/howto-get-full-path-of-current-file-in-vim is the actual file is the dirname of the file is the full path of the file. Use what you prefer. In order to save files, just

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment