Vim Stores the Current Buffer's Path in a Register
Registers in (n)vim contain a lot of super useful data. To wit, the %
register stores the path of the current buffer. Some useful things we can do with this register:
-
Write the path of the current buffer into the file in
Insert Mode
:Ctrl + R
,%
-
If in
Normal Mode
:"%p
-
Copy the path to the clipboard: run the command
"let @+=@%
(copy the%
buffer into the+
buffer, which is usually used by the system clipboard), or echo it