├── ReadMe.md └── plugin └── javap.vim /ReadMe.md: -------------------------------------------------------------------------------- 1 | # javap-vim 2 | 3 | ## Overview 4 | 5 | This small plugin calls the [`javap`](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javap.html) 6 | tool on `.class` files opened in Vim, which allows you to read the decompiled bytecode of a JVM class file 7 | instead of a useless binary representation of it. It works for files on the disk as well as inside zip/jar archives. 8 | 9 | ## Prerequisites 10 | 11 | You should have [Java](http://www.java.com) of any version installed, and `javap` must be accessible via your `PATH`. 12 | 13 | ## Installation 14 | 15 | ### [Pathogen](https://github.com/tpope/vim-pathogen) 16 | 17 | $ git clone https://github.com/udalov/javap-vim ~/.vim/bundle/ 18 | 19 | ### [Vundle](https://github.com/gmarik/Vundle.vim) 20 | 21 | Add `Plugin 'udalov/javap-vim'` to your `~/.vimrc` and run `PluginInstall`. 22 | 23 | ### Manual 24 | 25 | 1. `mkdir -p ~/.vim/plugin` 26 | 2. `cp plugin/javap.vim ~/.vim/plugin/javap.vim` 27 | 3. Restart Vim 28 | 29 | ##### Enjoy! 30 | -------------------------------------------------------------------------------- /plugin/javap.vim: -------------------------------------------------------------------------------- 1 | " javap.vim 2 | " Maintainer: Alexander Udalov 3 | " Version: 1.4 4 | 5 | if exists("javap_loaded") 6 | finish 7 | endif 8 | 9 | if !exists("g:javap_prg") 10 | let g:javap_prg = "javap -c -v -p -s" 11 | endif 12 | 13 | let g:javap_loaded = 1 14 | 15 | augroup javap 16 | autocmd! 17 | 18 | autocmd BufReadPre,FileReadPre *.class setlocal bin 19 | autocmd BufReadPost,FileReadPost *.class call JavapCurrentBuffer() 20 | autocmd BufAdd,BufCreate zipfile:*/*.class setlocal bin 21 | autocmd BufEnter zipfile:*/*.class call JavapCurrentBuffer() 22 | autocmd BufReadPost zipfile:*/*.class set filetype=java 23 | augroup END 24 | 25 | function! JavapCurrentBuffer() 26 | if &l:bin == 0 27 | return 28 | endif 29 | let tmp = tempname() . ".class" 30 | execute "silent w " . tmp 31 | silent! 1,$delete 32 | execute "silent read !" . g:javap_prg . " " . shellescape(tmp) 33 | normal! ggdd 34 | set filetype=java " TODO: doesn't work for zipfile:*/*.class 35 | setlocal nobin 36 | setlocal nomod ro 37 | endfunction 38 | --------------------------------------------------------------------------------