我使用自定义宏从系统剪贴板插入链接(在 OS X 和 Windows 上使用 Vim 7.3 测试,应该也适用于 Linux)并使用 formd 将生成的内联样式链接转换为引用样式当我认为合适的时候。
我的.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>
并使用这些来调用位于我的~/bin/ 文件夹中的formd:
" 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>
所以,我只需复制所需的链接,导航到单词(或使用视觉模式选择更多单词)以转换为链接并点击,4。如果我知道我将链接一个词或选择,但还没有 URL,我点击 ,3 并且宏将所需的括号插入为空。
点击,fr 会产生引用样式。如果需要,,fi 会返回到内联样式的链接。