RedPen IntelliJ IDEA Plugin

To make usage of RedPen among developers even easier we created an Intellij IDEA Plugin that also works with recent releases of other JetBrains IDEs. This plugin integrates RedPen text validation by adding a new RedPen inspection.

editor

By default, RedPen validation errors are underlined with red (Intellij error style), but you can change it to yellow (warning) or any other highlighting style in Settings -> Editor -> Inspections -> Code style issues -> RedPen Validation.

Alternatively, raw validation error messages can be listed by pressing Ctrl+Alt+Shift+R or via IDEA menu Analyze -> RedPen: List Errors having a file selected either in editor or in the Project pane.

Installation

The plugin is available in JetBrains Plugin Repository and can be installed the same way as any other IDEA plugin.

Just open Settings -> Plugins -> Browse Repository, and search for RedPen to install.

File formats

RedPen plugin supports the following file formats provided that the relevant plugins are installed:

  • Plain Text
  • Properties and Resource Bundles
  • Markdown
  • AsciiDoc

Language support

The plugin supports all default RedPen languages and variants (currently, English and Japanese). Language and variant are auto-detected for each file, but can be manually overridden per file via status bar widget. Manually chosen language will be saved to .idea/redpen/files.xml and therefore selection will be preserved within the project.

status-widget

Quick fixes

Some validation errors can be fixed via quick fix (Alt+Enter when cursor is on an error). If no specific fix is available, it will at least offer you to remove the erroneous text. We will be adding more specific quick fixes in later releases.

quick-fix

RedPen configuration

RedPen is highly customizable with its configuration files, where you can define specific validators, change their properties or configure valid and invalid symbols for your writing style.

All the same can be done using RedPen configuration in Settings -> Editor -> RedPen.

Screenshot from 2016-03-10 13-17-45

Validators can be disabled by unchecking them and their properties can be edited by double-clicking on them in the table. Different properties are separated by semicolons, so you can use comma-separated values for e.g. list properties, allowing to use short custom dictionaries (see Advanced Topics for details). Spaces after = are not trimmed, which allows you to have space-only values for e.g. start_from property.

Screenshot from 2016-03-10 13-18-01

If you already have configuration files in xml format that you previously used with command-line version of RedPen, you can import them in the Settings dialog using the Import button. In a similar way Export button allows you to save current configuration snapshot for future use in other projects.

Configuration is edited or imported for each language and variant separately. If you have changed the default configuration for some language and variant pair, it will be stored per project under .idea/redpen directory, so it can be shared with fellow developers by committing it to version control.

Advanced topics

In case you want to edit raw xml configuration files under .idea/redpen, make sure you either reload the project or switch focus away from IDEA for the changes to take effect.

Many RedPen validators support custom dictionaries. In most cases, they provide two properties, list and dict.

You can use the list property to provide a short inline dictionary, just separate words with commas, e.g. list=apples,oranges. Do not put spaces between the words.

Longer custom dictionaries can be put into separate files under .idea/redpen directory. Once the file is there, you can use the dict property to specify its name, e.g. dict=mywords.txt

JavaScriptValidator is a special one, it allows you to write additional custom validators in JavaScript. By default, you can put such scripts to .idea/redpen/js directory or override the location using script_path property. All custom validators from *.js files will be activated if JavaScriptValidator is enabled in Settings.

 

RedPen IntelliJ IDEA Plugin

2 thoughts on “RedPen IntelliJ IDEA Plugin

Leave a comment