Now, this may be something obvious and already solved and known to everyone, but I just thought of it, so have mercy ...
Is there a Vim plugin for (when writing markdown texts) that enables you to insert links in a way that Ctrl-L in here (StackOverflow) does it. Or something similar to it.
For example, I write in a link, http://www.google.com, press Ctrl-L, and it moves that link to the bottom of the page replacing it with [description][28] where 28 is the current (increase by one from last) identifier.
Anyone? Anything similar?
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.
I do not have an exact matching solution, but my vim-googurl plugin does part of the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With