Skip to content
Autocorrect for Vim built from scratch.
Vim script Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
plugin
.gitattributes
.gitignore
LICENSE.txt
README.markdown
corrections.vim
updatecorrections.sh

README.markdown

autocorrect.vim

This is an autocorrect plugin built from scratch. Every word added to the autocorrect file was spelled incorrectly by me at some point during my usage with Vim. In fact, several were added during the writing of this README file.

How to Install

I highly suggest the use of a Vim package manager plugin. Do a search in your favorite search engine, and you will see lots of examples.

VIM 8.0 does do a much better job with package management (check out this screen cast from one of the best, Drew Neil - every Vim user should read his book "Practical Vim"), although I personally use Vundle.vim. Check them out.

How to Use

By default, the autocorrect abbreviations are not executed to keep Vim startup time fast. There are two main functions/commands to get started. They are the commands:

:AutocorrectTryLoad

and

:AutocorrectForceLoad

By default, <leader>ta maps to AutocorrectTryLoad and <leader>fa maps to AutocorrectForceLoad. These will not overwrite existing mappings.

You can change the mappings to your preference with a line like

nmap {new map chars} <Plug>(AutocorrectTryLoad)
nmap {new map chars} <Plug>(AutocorrectForceLoad)

in your vimrc file.

For example, you could change it to be <leader>l using

nmap <leader>l <Plug>(AutocorrectTryLoad)

ForceLoadAutocorrect will always reread all the corrections. This is important when you add in corrections to your personal autocorrect file (See more on this here). AutocorrectTryLoad will do the same thing as AutocorrectForceLoad, but only if it has never been run before.

At this point, type your prose as normal and let the autocorrections do the hard work for you!

Extending

You can easily extend the list with your own personal autocorrect file. By default, once the autocorrect plugin has been loaded you can quickly add words to your personal autocorrect file with the mapping (standing for [A]dd Abbreviation):

<leader>a

This mapping will by default open up a .autocorrect file in your home directory, with the iabbrev command ready to go (:h iabbrev). If the first suggested option isn't what you want the correction to be, just change it.

You can modify the key binding for adding words to the autocorrect list by mapping to:

nmap {new map chars} <Plug>(AutocorrectAddToAbbrev)

Can I have this automatically loaded for particular filetypes?

Of course. All you have to do is add a List of filetypes to the variable g:AutocorrectFiletypes in your vimrc. As an example,

let g:AutocorrectFiletypes = ["text","markdown","tex"]

Be aware these are case sensitive as they are directly put into an autocommand behind the scenes like:

autocmd FileType text,markdown,tex AutocorrectTryLoad

Can I change the default location of the ~/.autocorrect file?

Yes you can. Just put something like

let g:AutocorrectPersonalFile='~/mydirectory/mynewfile.anyextension'

in your vimrc file.

Your corrections are terrible and I want to build my own list.

You can do that as well. To disable loading my list, just set the variable g:AutocorrectDisableBuiltIn in your vimrc to anything. Now only the personal autocorrect file will be sourced. Example:

let g:AutocorrectDisableBuiltIn = 1

Now you can start building up your own personal autocorrect list without any of my mistakes adding cruft!

Typical Workflow

I typically will just write and type quickly, and then use the [s command to move backwards through the incorrect spellings. Then I use the <leader>a mapping to add the autocorrection, press ZZ to save and exit the file, and then use 1z= to take the first autocorrection if the correct word appeared in the personal autocorrect file, or just z= if I want to see the other spell check options.

Additional Notes

Note that the personal autocorrect file is simply sourced as a vimscript file. So if you put other commands besides iabbrev in there, Vim will attempt to execute them. So if you put silly things in there and exceptions result, that will be on you.

How was this built?

This list was built slowly, one word at a time, and only words that I have actually typed incorrectly with my own fingers are on the list. This list was not generated by some script. Because of this, I feel there is much less waste and more crazy misspelling that occurs in practice.

I don't plan on stopping using Vim for a long time, so this is only going to grow, but I figured everyone should reap the benefits of this.

You can’t perform that action at this time.