<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>22 idea street &#187; Autocorrect</title>
	<atom:link href="http://22ideastreet.com/blog/tag/autocorrect/feed/" rel="self" type="application/rss+xml" />
	<link>http://22ideastreet.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 19 Aug 2010 17:12:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Vim Word Processing</title>
		<link>http://22ideastreet.com/blog/2008/11/06/vim-word-processing/</link>
		<comments>http://22ideastreet.com/blog/2008/11/06/vim-word-processing/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 03:30:16 +0000</pubDate>
		<dc:creator>Anthony Panozzo</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Autocorrect]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://22ideastreet.com/blog/?p=335</guid>
		<description><![CDATA[I&#8217;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 [...]<p><br/><br/>Original article:  <a href="http://22ideastreet.com/blog/2008/11/06/vim-word-processing/">Vim Word Processing</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;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.</p>
<p>Of course, there is a problem when I have to type in other programs.  For example, in OpenOffice, I routinely hit <code>j</code> a few times, and am surprised when that letter actually pops into the screen instead of moving the cursor around.</p>
<p>To overcome this, I&#8217;ve been messing around with ways to make Vim more friendly to general writing.  Here&#8217;s what I&#8217;ve done or found:</p>
<h4>Autocorrect</h4>
<p>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&#8217;s tough to do by default in vim.  When you type &#8216;teh&#8217; 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.</p>
<p>Example:</p>
<pre>
iabbrev teh the
</pre>
<p>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 &#8216;teh&#8217; with this, &#8216;Teh&#8217; doesn&#8217;t get changed.  So it seems like there needs to be a more systematic approach.</p>
<p>I was looking around, and couldn&#8217;t find a nice native file that had corrections out there.  Fortunately, Wikipedia has <a href="http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines">a machine-readable list of common misspellings</a>!  So this was a great start.  There were about 4000 changes that were in there.  Here&#8217;s a sample:</p>
<pre>
aggreement->agreement
aggregious->egregious
aggresive->aggressive
agian->again
agianst->against
agina->again, angina
agin->again
aginst->against
agravate->aggravate
agre->agree
agred->agreed
agreeement->agreement
</pre>
<p>There are a few like &#8216;agina&#8217; that have multiple choices, so I picked the one that was most common.  I don&#8217;t really type &#8216;angina&#8217; all that often.  Then again, the string distance is pretty huge there.  So there are probably some that are a stretch, but it&#8217;s a great start.</p>
<p>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.</p>
<p><a href="http://www.vim.org/scripts/script.php?script_id=2429">Here is the script, generator, and product.</a></p>
<p>The only limitation that I found is that dashes and apostrophes in the word to be corrected don&#8217;t seem to work, and I couldn&#8217;t figure out how to escape them.  And obviously sourcing thousands of lines of Vim commands takes a noticeable amount of time.</p>
<h4>Spelling correction</h4>
<p>Built into Vim nowadays.  Just need to type <code>:set spell</code>.  If it complains, you might need to set the spelling language.</p>
<table>
<tr>
<td>Spelling suggestions</td>
<td style="padding-left: 10px;"><code>z=</code></td>
</tr>
<tr>
<td>Previous misspelling</td>
<td style="padding-left: 10px;"><code>[s</code></td>
</tr>
<tr>
<td>Next misspelling</td>
<td style="padding-left: 10px;"><code>]s</code></td>
</tr>
<tr>
<td>Add current word to dictionary</td>
<td style="padding-left: 10px;"><code>zg</code></td>
</tr>
<tr>
<td>Undo adding current word to dictionary</td>
<td style="padding-left: 10px;"><code>zug</code></td>
</tr>
</table>
<h4>Word Processing Mode</h4>
<p>I commonly use a few things when doing word processing, so here&#8217;s a handy function that you can add to your .vimrc and modify as you see fit.</p>
<pre>
cabbr wp call Wp()
fun! Wp()
  set lbr
  source $VIM/vimfiles/autocorrect.vim
  set guifont=Consolas:h14
  nnoremap j gj
  nnoremap k gk
  nnoremap 0 g0
  nnoremap $ g$
  set nonumber
  set spell spelllang=en_us
endfu
</pre>
<p>You can add the preceding block to your .vimrc, and then invoke it with <code>:wp</code>.</p>
<p><br/><br/>Original article:  <a href="http://22ideastreet.com/blog/2008/11/06/vim-word-processing/">Vim Word Processing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://22ideastreet.com/blog/2008/11/06/vim-word-processing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
