Vim Tips Wiki
No edit summary
Tag: sourceedit
(8 intermediate revisions by 7 users not shown)
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
Jar files are really just zip files, and you can browse them from within Vim simply by treating them the same as Vim treats zip files.
+
Jar files are zip files, and you can browse them from within Vim simply by treating them the same as Vim treats zip files.
   
If you want to figure out how to do this yourself, simply read {{help|new-filetype}} and zipPlugin.vim in your runtime/plugins directory.
+
If you want to figure out how to do this yourself, read {{help|new-filetype}} and zipPlugin.vim. The latter is a plugin distributed with Vim: in Vim, put the cursor on <code>$VIMRUNTIME/plugin/zipPlugin.vim</code> and type <code>gf</code>.
 
For the impatient, just place the following in a file named ~/.vim/ftdetect/jar.vim (if you're on Unix):
 
   
 
For impatient people, just place the following in a file named <code>~/.vim/ftdetect/jar.vim</code> (on Unix systems) or <code>$HOME/vimfiles/ftdetect/jar.vim</code> (on Windows systems):
 
<pre>
 
<pre>
 
au BufRead,BufNewFile *.jar,*.war,*.ear,*.sar,*.rar set filetype=zip
 
au BufRead,BufNewFile *.jar,*.war,*.ear,*.sar,*.rar set filetype=zip
 
</pre>
 
</pre>
   
If you Vim a jar file now, you'll be able to browse it.
+
If you open a jar file in Vim, you will be able to browse it. If that does not work, update to a recent version of Vim with zipPlugin installed.
  +
  +
==Comments==

Revision as of 02:54, 14 November 2015

Tip 1259 Printable Monobook Previous Next

created 2006 · complexity basic · author emmby · version 7.0


Jar files are zip files, and you can browse them from within Vim simply by treating them the same as Vim treats zip files.

If you want to figure out how to do this yourself, read :help new-filetype and zipPlugin.vim. The latter is a plugin distributed with Vim: in Vim, put the cursor on $VIMRUNTIME/plugin/zipPlugin.vim and type gf.

For impatient people, just place the following in a file named ~/.vim/ftdetect/jar.vim (on Unix systems) or $HOME/vimfiles/ftdetect/jar.vim (on Windows systems):

au BufRead,BufNewFile *.jar,*.war,*.ear,*.sar,*.rar set filetype=zip

If you open a jar file in Vim, you will be able to browse it. If that does not work, update to a recent version of Vim with zipPlugin installed.

Comments