Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently noticed vim/vimdiff can open links (using curl, it seems), which is an awesome feature. I wanted to use it today, like this:

vimdiff deps https://raw.github.com/symfony/symfony-standard/v2.0.10/deps

But the https:// does not seem to trigger this awesome mechanism too. There is no authentication on this page, I think https:// is just there to provide data encryption. How can I force vim to recognize the https:// protocol?

share|improve this question
2  
I'm looking through the netrw plugin source, which handles http files, and it doesn't handle https; I'm seeing if there's an easy way to fix, but it seems it's not as simple as adding a ,https:// like I've done for other things. –  Kevin Feb 8 '12 at 16:35
    
Then maybe I should report a bug, but where? –  greg0ire Feb 8 '12 at 17:03
add comment

2 Answers

As I said in a comment, the netrw plugin, which handles http://, doesn't handle https:// (this from looking at the plugin code). I went into the code and got https:// working (no guarantees it's bug-free, but it worked for the couple sites I tried). I've created a pair of patches, for netrw.vim and netrwPlugin.vim. Here's how to apply them, keeping the originals untouched and the patched versions in your local configuration:

  • Make sure you have a ~/.vim/autoload and ~/.vim/plugin directory.
  • Download the patches, remember where you saved them (I'll assume it's at ~/.vim/patches/netrw.patch and ~/.vim/patches/netrwPlugin.patch)
cp /usr/share/vim/vimcurrent/autoload/netrw.vim ~/.vim/autoload
cp /usr/share/vim/vimcurrent/plugin/netrwPlugin.vim ~/.vim/plugin
patch ~/.vim/autoload/netrw.vim ~/.vim/patches/netrw.patch
patch ~/.vim/plugin/netrwPlugin.vim ~/.vim/patches/netrwPlugin.patch

This works on my vim, 7.3, hopefully yours too. If not, use the changes as a guide and see if you can hack it.


In case the pastebins disappear, here they are:

netrwPlugin.patch

56c56
<  au BufReadCmd   ftp://*,rcp://*,scp://*,http://*,dav://*,davs://*,rsync://*,sftp://* exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))
---
>  au BufReadCmd   ftp://*,rcp://*,scp://*,http://*,https://*,dav://*,davs://*,rsync://*,sftp://*   exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))

netrw.patch

682c682
<    if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^http://'
---
>    if choice =~ "^.*[\/]$" && b:netrw_method != 5 && choice !~ '^http://' && choice !~ '^https://'
835c835
<    elseif     b:netrw_method  == 5
---
>    elseif     b:netrw_method  == 5 || b:netrw_method  == 50
850c850,854
<       exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)
---
>       if b:netrw_method  == 5
>        exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)
>       else 
>        exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape("https://".g:netrw_machine.b:netrw_fname,1)." ".g:netrw_http_xcmd." ".shellescape(tmpfile,1)
>       endif
853c857,861
<       exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)
---
>       if b:netrw_method == 5 
>        exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.b:netrw_fname,1)
>       else 
>        exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("https://".g:netrw_machine.b:netrw_fname,1)
>       endif
865c873,877
<      exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)
---
>      if b:netrw_method == 5
>       exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("http://".g:netrw_machine.netrw_html,1)
>      else 
>       exe s:netrw_silentxfer."!".g:netrw_http_cmd." ".shellescape(tmpfile,1)." ".shellescape("https://".g:netrw_machine.netrw_html,1)
>      endif
1565a1578
>   let httpsurm = '^https://\([^/]\{-}\)\(/.*\)\=$'
1598a1612,1618
>   " Method#5.5: https://user@hostname/...path-to-file {{{3
>   elseif match(a:choice,httpsurm) == 0
> "   call Decho("https://...")
>    let b:netrw_method = 50
>    let g:netrw_machine= substitute(a:choice,httpsurm,'\1',"")
>    let b:netrw_fname  = substitute(a:choice,httpsurm,'\2',"")
> 
7075c7095
<   if w:netrw_method == 2 || w:netrw_method == 5
---
>   if w:netrw_method == 2 || w:netrw_method == 5 || w:netrw_method == 50
share|improve this answer
    
The netrwPlugin.patch fails to apply on my version of the file. I'm using Fedora, which ships vim 7.3, and I tried to apply the patch "manually" by editing the file but I get strange errors : Erreur détectée en traitant function netrw#Nread..netrw#NetRead..<SNR>35_NetrwMethod : ligne 86 : E121: Variable non définie : httpsurm E116: Arguments invalides pour la fonction match(a:choice,httpsurm) == 0 E15: Expression invalide : match(a:choice,httpsurm) == 0 "NetrwMessage" --Le tampon est vide-- I mailed about this thread to the address I found here : github.com/vim-scripts/netrw.vim –  greg0ire Feb 8 '12 at 22:04
    
Got the same problem at work with Ubuntu, but with a different error : curl complains about dav not being enabled. Here is the content of my netrwPlugin file : hastebin.com/jibenaluwi.xml –  greg0ire Feb 9 '12 at 9:11
1  
The plugin author answered me, he told me the latest version had support for https:// I should find it here : drchip.0sites.net/astronaut/vim/index.html#NETRW and try it later. –  greg0ire Feb 9 '12 at 16:51
add comment
up vote 2 down vote accepted

I mailed the author (drchip) here is his answer :

Hello,

Netrw v144b already supports https (you may get it from http://drchip.0sites.net/astronaut/vim/index.html#NETRW).

Thank you, Charles Campbell

to install it, I just had to download the .vba.gz file, unpack it, open it with vim, then follow the instructions (source the file with :so %).

My .vim is under version control, you can see the commit here : https://github.com/greg0ire/dotvim/commit/bfbe569ce070383c9f0a7b966ad23a35eefb651f

share|improve this answer
    
@jw013 : I forgot, done –  greg0ire Feb 10 '12 at 22:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.