Add spell check to Nano
If you've been reading Ghacks long enough, you know my favorite console-based text editor is Nano. Nano is simple to use, efficient, and extensible. Nano can be used for many things: Writing, programming, editing configuration files, and more. Depending upon your needs, you might need to check the spelling of what you are writing or editing within Nano. Let's take a look at how you can add spell checking to this handy editor.
Out of the box, one thing that Nano is missing is spell checking. Nano does include the option for spell checking (you can even invokeÂ spell checking from within Nano, but it won't work). Why is this? Simple - Nano makes use of a specific spell checker that is not installed on most distributions by default. So even though Nano has the keyboard shortcut available for spell checking, you have to make it work. Let's see how.
Installing the spell checker
Nano depends upon the package spell for spell checking. This is simple to install, from the command line, if you follow these steps:
- Open up a terminal window.
- Issue the command
sudo apt-get install spell.
- Type your sudo password and hit Enter.
- Accept any dependencies (if necessary).
- Let the installation complete.
Once complete you are ready to use spell checking.
Check your spelling
Open up a document for editing within Nano. When you do this you should see the list of keyboard shortcuts along the bottom of the screen. Of those shortcuts the ^T shortcut should be listed. That will invoke spell checking.
With your document open hit Ctrl-t to begin the check. Figure 1 shows the Nano spell checking in action. Spell will begin at the top of your document and continue on until it comes across a word it does not recognize. When it lands on a mis-spelled (or unrecognizable) word it will stop and ask you to correct the spelling of the misspelled word. Spell will not offer suggestions for replacements. Instead Spell will simply allow you to edit the misspelled word. Once you've edited the word you will have the chance to change all instances of the misspelled word. To replace a single instance just retype the word and hit enter. You will be asked if you want to replace that instance. If you want to only replace that instance hit Y (for yes) or, if you want to replace all instances hit A (for all) and all instances of the misspelled word will be replaced. If you have misspelled your correction just hit Ctrl-c to cancel the replacement.
Once Nano is finished with the spell checking it will inform you by saying so. Since there is nothing automated or fancy about Nano you will need to remember to save your changes made to your document when you exit (using Ctrl-x) the editor.
Most users have grown accustomed to auto-spell checks that make spelling suggestions to the users. That's not Nano. Nano wants you to think for yourself. It's not perfect, but it's as close to spell check as you will find with Nano.Advertisement