command line spell checking

I often edit files with command line tools such as vim and personally find spell checking invaluable.

Two high yield tips I have found:

VIM spell checking

vim has built-in spell checking functionality. I add this to ~/.vimrc

These options are a little more than just spell checking mind you:

" Show line numbers
set number

" Prevent vim from emulating vi
set nocompatible

" Syntax highlighting
syntax on

" Set automatic indentation
set autoindent
set smartindent

" Set tabs at 4 spaces
set tabstop=4
set shiftwidth=4

" Show matching [] and {}
set showmatch

" Spell check on
set spell spelllang=en_us
setlocal spell spelllang=en_us

" Toggle spelling with the F7 key
nn <F7> :setlocal spell! spelllang=en_us<CR>
imap <F7> <C-o>:setlocal spell! spelllang=en_us<CR>

" Spelling
highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline

" where it should get the dictionary files
let g:spellfile_URL = ''

Those options highlight and underline misspelled or unrecognized words.
Some keyboard shortcuts to navigate and correct words

]s – move to next misppelled word
[s – move to previous misspelled word
z= – show list of correction options

4]s skip to 4th mispelled word, etc.


See vim spelling documentation for details.


Aspell provides very similar functionality if you wish to spell check a document.

aspell check README

You then navigate with the keyboard

i – ignore
a – add to (user) dictionary
[0-9] – replace options
r- replace x1
R – replace all

In the event you need to revert changes, aspell saves a copy of the original document with a ~ at the end, in this example, README~



Update: At the advice of dominiko (see comments) I took LanguageTool for a test drive. LanguageTool does both spelling (with either hunspell or the built in vim spell checker) and grammar checking. I had to use the snapshot of language tool.

This vim plugin works with java-1.7.0-openjdk and will integrate with libreoffice.

I found LanguageTool to be a very nice addition and would advise taking it for a test drive.


This entry was posted in Linux. Bookmark the permalink.

11 Responses to command line spell checking

  1. dominiko says:

    In Vim, you can also do grammar checking using the LanguageTool plugin.

  2. bodhi.zazen says:

    /me goes off to check out vim grammar tool.

  3. Kevin Kofler says:

    You should be using hunspell rather than aspell, it’s more modern and more powerful, and it’s what almost all the GUI apps in Fedora use (because it’s better).

  4. bodhi.zazen says:

    Hey Kevin Kofler, thank you for the recommendation. I did not really like the hunspell command line interface.

  5. Matthew Fernandez says:

    Another good option is ispell with the -t flag for spell checking a LaTeX document. On the other hand, maybe nobody uses LaTeX outside of academia these days ;)

  6. bodhi.zazen says:

    @dominiko – The LanguageTool plugin looked good, but I could not get it working. The graphical tool works, just not the vim plugin.

  7. dominiko says:

    > @dominiko – The LanguageTool plugin looked
    > good, but I could not get it working. The graphical
    > tool works, just not the vim plugin.

    Let’s make it work. What error do you get?
    What settings did you use in Vim?

    Which version of LanguageTool did you download?

    Can you try the nightly build of LanguageToo available here:

    Does LanguageTool work from the command line
    with something like this for example:

    $ echo “This is is an error.” | \
    java -jar LanguageTool.jar -l en

    This should indicate an error (repeated word).

    In Vim, you can also go through “:help LanguageTool”.

  8. bodhi.zazen says:

    @dominiko – The nightly build of LanguageTool resolved the problem, thank you for the tip.

  9. Raafaeel says:

    Hi Jadu, Please update your blog with new tips. I was very much imeersspd the way you present tips. Any ways, I want to share two useful tips for vim editor. 1. Whenever you open vim, it will takes you the position where you left off last time in command mode. But if your requirement is to know the last insert position in a file, press “gi” without quotes.2. Number conversion in vim. Hexadecimal to decimal :echo 0x10 16Decimal to hexadecimal :echo printf (‘%x\n’, 10) a

  10. Pingback: The Most Common Spelling Errors - Unemployblog

  11. Cecilia says:

    Hot damn, loiknog pretty useful buddy.

Leave a Reply

Your email address will not be published. Required fields are marked *