Last Updated: July 31, 2016
· ryrych

Getting GitHub url to frozen selection

You have a repo on GitHub. Every once and a while you want to share a link to a chunk you have just selected in Vim. With fugitive.vim it’s as simple as selecting text and running :Gbrowse. The advantage is that you get frozen (changes from from current git HEAD) link, not the relative one which could potentially be wiped out in the future.


1) Select changes

" Center screen on next/previous selection.
nmap N Nzz
" Last and next jump should center too.
nmap <C-o> <C-o>zz
nmap <C-i> <C-i>zz

2) :'<,'>Gbrowse
3) You get the link!

That’s it!