Vim Tips Wiki
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.


From :help zip-extension a .jar file can be unzipped with the following in vimrc

au BufReadCmd *.jar call zip#Browse(expand("<amatch>"))