English Grammar and Style Checking in Gedit

I love gedit as a MarkDown editor. It’s simple, clean, fast and easy to configure. It does almost everything I need from a simple editor. The only feature that I miss is a grammar checker and style checker. So I got one working in gedit.

I got grammar checking working in gedit by combining two tools:

  1. gedit External Tools Plugin
  2. write-good

The external tools plugin allows gedit to execute external commands which can manipulate or process the current document. write-good is a command-line tool that will evaluate English text that is passed to it and highlight grammar errors and dubious style choices such as passive voice.

Let’s combine them!

Installing and Configuring

The external tools plugin should be shipped as either default plugin with gedit or in an additional package labeled something like gedit-plugins. Check your package manager to see if you need to install the additional packages.

Next, enable external tools in gedit by going:

Settings Hamburger -> Preferences -> Plugins

With that enabled install write-good. The git repository recommends using npm with the following command:

npm install write-good

You may need to get npm installed first.

With write-good enabled and external tools enabled we just need to configure a new external tools shortcut/script.

Creating a new external tool

First, open the external tools creation dialogue at:

Setting Hamburger -> Manage External Tools...

Create a new tool by clicking on the + sign at the bottom of the window on the left. Give the tool a name and hit Enter.

Now, we can put the contents of the tool in the large dialogue box, the one with a shebang ( #!/bin/sh ) at the top. We only need a single line after the shebang:

#!/bin/sh
write-good $GEDIT_CURRENT_DOCUMENT_NAME

The variable $GEDIT_CURRENT_DOCUMENT_NAME should be fairly obvious as to what it does.

write-good accepts several options to enable and disable its grammar checks. These are:

  --parse            activate parse-happy output and a more conventional Unix exit code
  --eprime           activate the 'E-Prime' check and deactivate all other checks that aren't explicitly activated
  --yes-eprime       activate 'E-Prime' check, without deactivating the other checks
  --no-weasel        deactivate the 'weasel word' check
  --weasel           activate the 'weasel word' check and deactivate all other checks that aren't explicitly activated
  --no-illusion      deactivate the 'lexical illusion' check
  --illusion         activate the 'lexical illusion' check and deactivate all other checks that aren't explicitly activated
  --no-so            deactivate the 'so' check
  --so               activate the 'so' check and deactivate all other checks that aren't explicitly activated
  --no-thereIs       deactivate the 'there is' check
  --thereIs          activate the 'there is' check and deactivate all other checks that aren't explicitly activated
  --no-passive       deactivate the 'passive voice' check
  --passive          activate the 'passive voice' check and deactivate all other checks that aren't explicitly activated
  --no-adverb        deactivate the 'adverb weakens meaning' check
  --adverb           activate the 'adverb weakens meaning' check and deactivate all other checks that aren't explicitly activated
  --no-tooWordy      deactivate the 'too wordy' check
  --tooWordy         activate the 'too wordy' check and deactivate all other checks that aren't explicitly activated
  --no-cliches       deactivate the 'clichés' check
  --cliches          activate the 'clichés' check and deactivate all other checks that aren't explicitly activated

You can add to the external tool command to modify exactly what write-good will alert you about. Here the passive voice check is disabled:

#!/bin/sh
write-good --no-passive $GEDIT_CURRENT_DOCUMENT_NAME

Next, select a shortcut key for the tool. I eventually settled on Shift+Ctrl+P for no other reason other than it was the first one that worked.

Finally, ensure that you have selected the output to be “Display in bottom pane”.

Using the grammar checker

When you press the quick key to activate the tool the bottom pane will appear along with all of the suggestions that write-good has made. This makes it more difficult to use than a standard linter as nothing highlighted in the text.

write-good will give you a line number and quote the problem text in addition to supplying the reason that it flagged that text. Here is a passive voice warning:

-------------
d quote the problem text in addition to supplying the reason that it flagged tha
"in addition" is wordy or unneeded
line 93 column 67
-------------

Enabling line numbers in the preferences makes reviewing the write-good suggestions easier.