Source a vimrc from a webpage?

3

1

I work with lots of different servers and would like to unify my vimrc across them all. I see that vim has the source command, which I'm assuming works similar to bash. In bash, to source a file from a webpage you go

. <(curl -s domain.com)

How can I do this with vim? I'm aware that I can instead apply each vim setting by adding an alias like so:

alias vim="vim +'colorscheme elflord'"

but I'd rather not pass thru all my settings like that. I don't want to have to create a file on the local server I'm on, hence the desire to instead source into the local session. Any ideas would be appreciated!

Egrodo

Posted 2016-10-27T22:55:20.747

Reputation: 69

1That's really weird. I'm absolutely certain $ vim -u http://foo.bar/myvimrc worked before. I've used that method countless times but I can't make it work right now. – romainl – 2016-10-28T07:27:41.503

1@romainl: Replace -u with -S; the netrw plugin first needs to be loaded (and it only triggers on :source). – Ingo Karkat – 2016-10-31T10:52:26.463

@IngoKarkat THAT'S IT I LOVE YOU. – romainl – 2016-10-31T11:05:16.140

Answers

4

Vim ships with the netrw plugin, which enables transparent access of web (or SSH / FTP / etc.) resources, even for :source.

$ vim -S http://foo.bar/myvimrc

Note: You cannot use vim -u ..., because the netrw plugin first needs to be loaded, and plugin loading only comes after processing of the ~/.vimrc. Unless you reconfigure the built-in / any locally installed plugins, this change of ordering shouldn't matter.

Ingo Karkat

Posted 2016-10-27T22:55:20.747

Reputation: 19 513