Vim Tips Wiki

Use gf to open a file via its URL

1,613pages on
this wiki
Revision as of 05:43, July 13, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 691 Printable Monobook Previous Next

created 2004 · complexity intermediate · author Xiangjiang Ma · version 6.0

To make gf work for a URL, say, file:///C:/myfile.txt, I have the following in my vimrc on Windows:

au BufReadCmd file:///* exe "bd!|edit ".substitute(expand("<afile>"),"file:/*","","")


How about extending it for http://x.y

For network file like http:// ftp:// etc, I guess it is better to use netrw plugin.


  • Handle escaped characters like %20 for spaces.

--Fritzophrenic 16:12, January 6, 2010 (UTC)

Around Wikia's network

Random Wiki