Wikia

Vim Tips Wiki

Changes: Use gf to open a file via its URL

Edit

Back to page

(Comments: need to handle escaped characters)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=690
 
|previous=690
 
|next=692
 
|next=692
|created=April 5, 2004
+
|created=2004
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Xiangjiang Ma
 
|author=Xiangjiang Ma
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
To make <tt>gf</tt> work for a URL, say, <tt>file:///C:/myfile.txt</tt>, I have the following in my vimrc on Windows:
+
To make <code>gf</code> work for a URL, say, <code>file:///C:/myfile.txt</code>, I have the following in my vimrc on Windows:
   
 
<pre>
 
<pre>
Line 19: Line 19:
   
 
==Comments==
 
==Comments==
How about extending it for <tt>http://x.y</tt>
+
How about extending it for <code>http://x.y</code>
   
 
For network file like http:// ftp:// etc, I guess it is better to use netrw plugin.
 
For network file like http:// ftp:// etc, I guess it is better to use netrw plugin.

Latest revision as of 05:43, July 13, 2012

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:/*","","")

CommentsEdit

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

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


 TO DO 

  • Handle escaped characters like %20 for spaces.

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

Around Wikia's network

Random Wiki