I’ve been using Vim for about a year now, and am pretty much addicted. Once I reached a certain level of proficiency, no other editor seems to be even close. The keys are very intuitive to me now, as is modal editing.
Of course, there is a problem when I have to type in other programs. For example, in OpenOffice, I routinely hit
j a few times, and am surprised when that letter actually pops into the screen instead of moving the cursor around.
To overcome this, I’ve been messing around with ways to make Vim more friendly to general writing. Here’s what I’ve done or found:
This section outlines my major actual contribution. The rest are just tips. Autocorrect is a key feature of almost any word processing program, and it’s tough to do by default in vim. When you type ‘teh’ and then have to go back and fix it, you are much less efficient. Vim has the concept of abbreviations, where you can map one word to another.
iabbrev teh the
Then you when you type in the whole word that matches, it will magically be replaced with the correction. Unfortunately, this takes quite a bit of time to build up automatically. Plus, while you catch 'teh’ with this, 'Teh’ doesn’t get changed. So it seems like there needs to be a more systematic approach.
I was looking around, and couldn’t find a nice native file that had corrections out there. Fortunately, Wikipedia has a machine-readable list of common misspellings! So this was a great start. There were about 4000 changes that were in there. Here’s a sample:
There are a few like 'agina’ that have multiple choices, so I picked the one that was most common. I don’t really type 'angina’ all that often. Then again, the string distance is pretty huge there. So there are probably some that are a stretch, but it’s a great start.
Then I created a script to parse this file and do some important changes. Essentially, if a word to be corrected starts with a lowercase letter, it also should be changed when the mistake is capitalized.
The only limitation that I found is that dashes and apostrophes in the word to be corrected don’t seem to work, and I couldn’t figure out how to escape them. And obviously sourcing thousands of lines of Vim commands takes a noticeable amount of time.
Built into Vim nowadays. Just need to type
:set spell. If it complains, you might need to set the spelling language.
Add current word to dictionary
Undo adding current word to dictionary
Word Processing Mode
I commonly use a few things when doing word processing, so here’s a handy function that you can add to your .vimrc and modify as you see fit.
cabbr wp call Wp()
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap $ g$
set spell spelllang=en_us
You can add the preceding block to your .vimrc, and then invoke it with