Vim插件,用于添加外部链接 [英] Vim plugin for adding external links

查看:83
本文介绍了Vim插件,用于添加外部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,这可能是显而易见的事情,已经为所有人解决,并且众所周知,但是我只是想到了,所以请仁慈...

Now, this may be something obvious and already solved and known to everyone, but I just thought of it, so have mercy ...

是否有一个Vim插件(用于编写降价文字时),使您可以通过此处的 Ctrl - L (StackOverflow)来插入链接.或类似的东西.

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.

例如,我写一个链接, http://www.google.com ,然后按 Ctrl - L ,它将链接移到页面底部,并用[description] [28]替换,其中28是当前(从最后一个开始递增).

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?

推荐答案

我使用自定义宏从系统剪贴板插入链接(在OS X和Windows上使用Vim 7.3进行了测试,也应在Linux上使用),并使用已形成,以便在我认为合适时将生成的内联样式链接转换为引用样式.

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.

我在.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:

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>

因此,我只复制所需的链接,导航到该单词(或使用可视模式选择更多单词)以变成链接并点击,4.如果我知道要链接一个单词或选区,但还没有URL,请按,3键,然后宏将所需的括号插入为空.

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.

命中,fr会产生引用样式.如果需要,,fi返回到内联样式的链接.

Hitting ,fr produces the reference-style. If needed, ,fi returns to inline-style links.

这篇关于Vim插件,用于添加外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆