Skip to content

Instantly share code, notes, and snippets.

@spalenza
Created February 19, 2016 17:31
Show Gist options
  • Save spalenza/d24200b5cfe0c2e55447 to your computer and use it in GitHub Desktop.
Save spalenza/d24200b5cfe0c2e55447 to your computer and use it in GitHub Desktop.
vim copy file path
" Convert slashes to backslashes for Windows.
if has('win32')
nmap ,cs :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
nmap ,cl :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>
" This will copy the path in 8.3 short format, for DOS and Windows 9x
nmap ,c8 :let @*=substitute(expand("%:p:8"), "/", "\\", "g")<CR>
else
nmap ,cs :let @*=expand("%")<CR>
nmap ,cl :let @*=expand("%:p")<CR>
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment