Skip to content

Instantly share code, notes, and snippets.

@eloytoro
Created June 3, 2018 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eloytoro/2c0d33b722da80a873b743fe450b4fd7 to your computer and use it in GitHub Desktop.
Save eloytoro/2c0d33b722da80a873b743fe450b4fd7 to your computer and use it in GitHub Desktop.
" ----------------------------------------------------------------------------
" Yank Position
" ----------------------------------------------------------------------------
function! s:YankPosition()
let @+=@%.'#L'.line('.')
let @r=@%
echo 'copied "'.@+.'"'
endfunction
nnoremap <silent> yp :call <sid>YankPosition()<CR>
function! s:PasteRelative()
if executable("perl")
" yes im using perl, shoot me
return "'".system("perl -MFile::Spec -MFile::Basename -e 'print File::Spec->abs2rel(shift, dirname(shift))' ".@r." ".@%)."'"
elseif
" yes im using node, shoot me
return "'".system("node -e \"(p => process.stdout.write(p.relative(p.dirname('".@%."'), '".@r."')))(require('path'))\"")."'"
endif
return "¯\\_(ツ)_/¯"
endfunction
nnoremap <silent> yP "=<sid>PasteRelative()<C-M>p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment