Vjde

Link: [http://www.vim.org/scripts/script.php?script_id=1213]
Command reference: [http://media.cqic.com.cn/vjde-tut/list.htm]
This plugin makes use of some other plugins, such as jcommenter, to provide many useful features.

To make all features work, you must set environment variable JAVA_HOME.

Here is the document which is in Chinese currently.
I summarize some useful commands:

insert comments

The document says \jc can be used in normal mode. Unfortunately, it does not work.
Solution:
In file vjde_java_utils.vim, change
nnoremap <buffer> <silent> <Leader>jc :call VjdeGenerateConstructor()<CR>
to
nnoremap <buffer> <silent> <Leader>jc :call JCommentWriter()<CR>
Then \jc can be used to insert comment automatically.

Package sort

Select imported packages in visual mode and use command \js to sort those packages based on their names.

Remove unreferenced packages

In a class declaration, use command \ri

Auto add packages

Move cursor to class name, and use command \ai.

Package extraction

Move cursor the full qualified class name (e.g. java.util.Vector), then use \je to put an import statement in the beginning of the file. The package name is removed from the class name.

java.util.Vector

=>
import java.util.Vector;
...
Vector

Try catch

Select statements you would like to enclose with try-catch, and use command \jt.

Getter/Setter generation

Move cursor to the variable for which setter and getter functions are to be generated, then use command \jg

Name completion

Code completion can used use to auto-complete type name, function parameter, imported packageā€¦
Command: Ctrl+x Ctrl+U
Then you use Ctrl+p or Ctrl+n to select a specific item in the list. Or you can select the blank item and use keyboard input to filter the items.
Ctrl+y: accept current selection
Ctrl+e: cancel current selection

Override function

use \oe to list all functions declared in super classes (both direct and indirect) of current class. Then input the number corresponding to the function you want to override.

Constant Refactoring

move cursor the string constant, select the whole string in visual mode by using command va", then use \en. You would be prompted to input a name for the variable.

More

Extract local variable and put it into the parent scope: \el
Make a local variable become a member variable of a class: \em
Make a variable become a parameter: \ep

vim
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License