Skip to content

Vim: yank current file path to clipboard

1 min read

Full absolute path:

:let @*= expand("%:p")

Relative path:

:let @*= expand("%")

File path with line number (useful for sharing):

:let @*=expand("%:p") . ":" . (line(".")+1)

Copy one register to another:

:let @a=@b