java_remove_imports - Man Page

remove import statements from Java source files


%java_remove_imports <matcher>... [file path]...


This macro removes import statements from Java source files. The script matches all non-whitespace content following the import [static] statement against all patterns provided via the -p flag and all simple class names against names provided by the -n flag.

File path arguments are handled the following way:

Order of arguments is irrelevant.

Matcher is one of:

-n <name>

Simple class name to be matched against the simple names of imported symbols. Names are matched for exact equality. Can be specified multiple times.

-p <pattern>

Regex patterns to be matched against imported symbols. Each imported symbol found in the code is matched against each pattern. Can be specified multiple times.


Example of usage:

%java_remove_imports src -n Nullable

Examples of patterns:


Written by Marián Konček.

Reporting Bugs

Bugs should be reported through the issue tracker at GitHub:

See Also


Referenced By


03/08/2023 Jurand