Created
June 3, 2018 15:55
-
-
Save eloytoro/2c0d33b722da80a873b743fe450b4fd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ---------------------------------------------------------------------------- | |
" 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