5

I have some strange troubles with opening an url in vim. Judging from this answer, this should be pretty easy, but when I'm doing this:

$ vim http://www.ietf.org/rfc/rfc7386.txt

I getting a message

:!links 'http://www.ietf.org/rfc/rfc7386.txt' -source > '/tmp/vmEga7/1.txt'

and empty buffer (there is no /tmp/vmEga7/1.txt file also). I don't fully understand, where I should look for the options that are related to the links (some vim options, xdg configuration, etc.) - probably someone know about this and can explain it to me?

UPD I'm trying to debug this problem

$ vim -V20vimlog http://www.ietf.org/rfc/rfc7386.txt

and here is the part of vimlog. Is this line

function netrw#Nread..netrw#NetRead..<SNR>24_FileReadable returning #1

means, that resulting temporary file isn't readable?

UPD I'm still struggling with this trouble, no luck. It's strange, but the same is perfectly working in NeoVim. I figured out, that everything is ok about temporary files (they are created well and are readable). It looks like temporary file should be opened here:

   " edit temporary file (ie. read the temporary file in)
   if     rfile =~ '\.zip$'
"    call Decho("handling remote zip file with zip#Browse(tfile<".tfile.">)")
    call zip#Browse(tfile)
   elseif rfile =~ '\.tar$'
"    call Decho("handling remote tar file with tar#Browse(tfile<".tfile.">)")
    call tar#Browse(tfile)
   elseif rfile =~ '\.tar\.gz$'
"    call Decho("handling remote gzip-compressed tar file")
    call tar#Browse(tfile)
   elseif rfile =~ '\.tar\.bz2$'
"    call Decho("handling remote bz2-compressed tar file")
    call tar#Browse(tfile)
   elseif rfile =~ '\.tar\.xz$'
"    call Decho("handling remote xz-compressed tar file")
    call tar#Browse(tfile)
   elseif rfile =~ '\.txz$'
"    call Decho("handling remote xz-compressed tar file (.txz)")
    call tar#Browse(tfile)
   else
"    call Decho("edit temporary file")
    NetrwKeepj e!
   endif

but when control flow reaches line NetrwKeepj e! nothing is happening.

  • See if :help netrw-debug will help you with its addtional information on your problem. – user21497 Nov 24 '15 at 19:39
4

I get a different result when I go this: the buffer consists of garbled text (gziped?). Perhaps your version of links and/or vim does something different with gzip-encoded text.

Netrw, the plugin bundled with Vim which reads URLs tries a bunch of different commands to get the source of a page, but you can also set it explicitly.

For example, to set it to curl:

" Command name
let g:netrw_http_cmd = 'curl'

" Arguments passed to the command
let g:netrw_http_xcmd = '-o'

Or you can try wget:

let g:netrw_http_cmd = 'wget'
let g:netrw_http_xcmd = '-q -O'

Also see :help g:netrw_http_cmd and :help g:netrw_http_xcmd.

  • I've tried to setup curl example, now I got this message: :!curl 'http://www.ietf.org/rfc/rfc7386.txt' -o '/tmp/vbA49BG/1.txt', but anyway there is nothing in directory /tmp/vbA49BG/. Whem I'm executing this command right from the terminal curl 'http://www.ietf.org/rfc/rfc7386.txt' -o '/tmp/vbA49BG/1.txt, everything is ok. It looks like something wrong with file creation. – erthalion Jun 25 '15 at 15:26
  • @erthalion This is also the case on my system. The /tmp/[...] directory is empty. This is I would expect, since tmp files are exactly that: temporarily... For some reason, the directory is removed later (perhaps there is a reason for this, but it could also be a bug). – Martin Tournoij Jun 25 '15 at 15:31
  • Not a bug. The directory is reused for other temporary files, and it's removed when you quit Vim. – lcd047 Jun 25 '15 at 15:43
  • @lcd047 temporary directory is empty even before I quit vim, is that ok? – erthalion Jun 25 '15 at 15:52
  • 1
    @erthalion Yes. On UNIX it's ok to delete files from disk while they are still open (the process holding them open won't notice). Doing this is a common practice with temporary files. – lcd047 Jun 25 '15 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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