Last Updated: February 25, 2016
· wojtekkruszewsk

Vim copy file name to clipboard


Copy current file path to "unnamed register":

let @"=@%

Then you can paste it in another vim buffer. If your Vim is configured to use system clipboard you can paste in another application (you might need to use let @* = instead, but it's a different story).

To copy only file name:

let @" = expand("%:t")

or just directory relative to working dir:

let @" = expand("%:h")