I want to create a command that will download a large file and save it to my local system. I am not interested in editing this file. I also would like to avoid a huge if block to see what downloaders are available. This is specific to the thesaurus which is why the auto spell download is not going to work.

I have thought the best thing to do would reuse the netrw logic since it was a trusted source for what system programs were available.

So I've tried this:

command! ThesaurusInstall call netrw#Obtain(0, "http://www.gutenberg.org/files/3202/files/mthesaur.txt", "$HOME/.vim/")

Which crashes because I'm not using the function right. I just want a Vim command I can put in my .vimrc which will download that thesaurus file to my .vim/ directory. How can I do this without making my own complicated conditions like

if `curl` … else if `wget` … else if …
  • 2
    Why would you use a text editor to download a file?
    – romainl
    Nov 7, 2016 at 20:33
  • Yes, we have perfectly good tools for this: curl and wget.
    – Ian Emnace
    Nov 8, 2016 at 3:13
  • So if I if execute('curl') and if execute('wget') are I not re-inventing the same thing the netrw plugin is doing. Why can I not use the netrw plugin functions to do this without having to build my own conditional statement? Does the netrw plugin not already have better fallback defaults? The aversion to reuse bundled code confuses me.
    – Sukima
    Nov 8, 2016 at 3:57
  • @romainl because it is convenient and Vim allows for transparent network access and curl or wget only work suboptimal on Windows. Nov 8, 2016 at 14:01
  • 1
    @Sukima you would use the Nread command from the netrw plugin. Have a look at my unicode plugin Nov 8, 2016 at 14:02

1 Answer 1


As @romainl and @Ian Emnace said in the comments you shouldn't do that with Vim. Here's why:

The unix tool philosophy is to have small programs to accomplish a particular task instead of trying to develop large monolithic programs to do a large number of tasks.

  • Vim is a text editor, even if it includes netrw which has some network capabilities, it is not meant to automate file downloads.
  • Furthermore downloading a thesaurus is not a task that you'll often do: You don't need to download it each time you source your vimrc.

It is more likely that you'll need to download a thesaurus when you install your vimrc (probably along with your other dotfiles) on a new machine. Thus what I would recommend is to:

  • Host your dotfiles on a git repository (this question mentions it and you can also google dotfiles github you'll get a lot of examples but you can use bitbucket or even a self hosted gitlab instead of github)
  • In this repository also host a bash script (or python or maybe go or whatever scripting language you're familiar with) that you'll execute when you install your dotfiles and which will download the spell files you need in the correct destination. If you already manage your dotfiles on github maybe you already have such a script which symlink your files or do this kind of things, it would be easy to add a wget call to this script.

This will be much easier to handle for you because languages like bash are tools which were made to automate process like downloading a file.

  • Completely agree. Could you help clarify why vim downloads spell fikes internally and why Vundle perform downloads if these are outside the scope of a text editor? I understand the reasoning. I understand the unix philosiphy. I was not trying to go against any right or wrong philosophy. I just wanted to know if and how it could be done. Learn about netrw internals better.
    – Sukima
    Nov 8, 2016 at 12:25
  • @Sukima I think that plugin manager are more than just downloaders since their main role is to add the plugin files to the runtimepath and make the plugins and their docs available to the user. About the spell files I have to say that it is a counter example to my answer. Personally I don't use the download feature: the spell files I needs are in my dotfiles repo and when I install my dotfiles on a new machine the spell files are installed too. Now my answer was simply reflecting my opinion and I certainly don't claim that it is an universal truth :-)
    – statox
    Nov 9, 2016 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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