Skip to content
qadzek edited this page May 8, 2024 · 18 revisions

To move all the URLs in the document body to the end of it, after a Links: header, add a file ~/.vim/ftplugin/gitcommit.vim with the following content:

let b:link_heading = 'Links:'
let b:link_heading_before = '^# ------------------------ >8 ------------------------$'
let b:link_skip_line = '^#'
let s:body_range = '1,/' . b:link_heading_before.'\|\V\^'.escape(b:link_heading,'\') . '\$/-1'

autocmd BufWrite <buffer> silent! exe s:body_range..'LinkConvertRange'

if exists(':Alias') != 2 || exists('b:gitcommit_aliases')
    finish
endif
let b:gitcommit_aliases = 1

Alias -buffer -range lc  LinkConvertRange
Alias -buffer        lo  LinkOpen
Alias -buffer        lp  LinkPeek
Alias -buffer        lj  LinkJump
Alias -buffer        lr  LinkReformat
Clone this wiki locally