Today I Learned

hashrocket A Hashrocket project

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
See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.