I use a custom macro to insert links from the system clipboard (Tested with Vim 7.3 on OS X and Windows, should work with Linux, too) and use formd to convert the resulting inline-style links to reference-style when I see fit.
I got these macros in my .vimrc
:
" Create a Markdown-link structure for the current word or visual selection with
" leader 3. Paste in the URL later. Or use leader 4 to insert the current
" system clipboard as an URL.
nnoremap <Leader>3 ciw[<C-r>"]()<Esc>
vnoremap <Leader>3 c[<C-r>"]()<Esc>
nnoremap <Leader>4 ciw[<C-r>"](<Esc>"*pli)<Esc>
vnoremap <Leader>4 c[<C-r>"](<Esc>"*pli)<Esc>
And use these to invoke formd
which lives in my ~/bin/
folder:
" Use formd to transfer markdown from inline to reference links and vice versa
" see: http://drbunsen.github.com/formd/
nmap <leader>fr :%! ~/bin/formd -r<CR>
nmap <leader>fi :%! ~/bin/formd -i<CR>
So, I just copy the needed link, navigate to the word (or use visual mode to select more words) to turn into a link and hit ,4
. If I know I'll link a word or selection but don't have the URL yet, I hit ,3
and the macro inserts the needed parentheses empty.
Hitting ,fr
produces the reference-style. If needed, ,fi
returns to inline-style links.