<?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>jamesoff.net &#187; email</title>
	<atom:link href="http://jamesoff.net/site/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesoff.net/site</link>
	<description>you heard</description>
	<lastBuildDate>Thu, 01 Sep 2011 17:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Using gvim to edit mail in Outlook</title>
		<link>http://jamesoff.net/site/2009/04/03/using-gvim-to-edit-mail-in-outlook/</link>
		<comments>http://jamesoff.net/site/2009/04/03/using-gvim-to-edit-mail-in-outlook/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 16:43:45 +0000</pubDate>
		<dc:creator>jamesoff</dc:creator>
				<category><![CDATA[Exim and email]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://jamesoff.net/site/?p=375</guid>
		<description><![CDATA[Before you go any further, this isn&#8217;t about having gvim embedded in Outlook, or using it automatically as an external editor. This method lets you use one keystroke to edit a mail in gvim and when you close gvim, it&#8217;s put back into the Outlook compose mail window. You will need: AutoHotkey, a keystroke mapping/scripting [...]]]></description>
			<content:encoded><![CDATA[<p>Before you go any further, this isn&#8217;t about having gvim embedded in Outlook, or using it automatically as an external editor.</p>

<p>This method lets you use one keystroke to edit a mail in gvim and when you close gvim, it&#8217;s put back into the Outlook compose mail window.</p>

<p><span id="more-375"></span></p>

<p><strong>You will need:</strong></p>

<ul>
<li><a href="http://www.autohotkey.com/">AutoHotkey</a>, a keystroke mapping/scripting application</li>
<li>My script (below)</li>
<li>gvim for Windows</li>
</ul>

<p><strong>Method:</strong></p>

<ol>
<li>Install AutoHotKey</li>
<li>Install gvim</li>
<li>Install my script into AutoHotKey (it appears at the end of this post). Note that my script has the gvim path hard-coded in and you may well need to change it.</li>
<li>Configure your Outlook to use plain text for composing mail.</li>
<li>Press <strong>Win-V</strong> with an Outlook compose window open and when the cursor is in the message pane</li>
</ol>

<p><strong>Serving suggestion:</strong></p>

<ul>
<li>Goes really well with <a href="http://home.in.tum.de/~jain/software/outlook-quotefix/">Outlook QuoteFix</a></li>
<li>gvim will be opened with the contents of the message window</li>
<li>Edit your mail in gvim and when done, save and quit</li>
<li>Your edited message is put back into the Outlook message window.</li>
</ul>

<p><strong>Additional notes:</strong></p>

<ul>
<li>At the moment, this only works with one mail at a time, as the file for the mail is statically named. If you try Win-V in a mail while you have another already opened, Bad Things will Happen.</li>
<li>You may want to adjust your vimrc file so that it uses the &#8220;mail&#8221; filetype for editing; I also have a mail.vim file with macros and things in it which I tell it to load for this. I pinched it off the web, I&#8217;m sure you can find it. The required vimrc lines are below.</li>
<li>If the cursor isn&#8217;t in the message pane of the Outlook compose window when you press Win-V (or if it moves there before you close the gvim window), things will probably go wrong.</li>
<li>I&#8217;ve tested this with Outlook 2003, gvim 7.2 and AutoHotkey 1.0.47.06.</li>
</ul>

<p>Here&#8217;s the optional vimrc line:</p>


<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">autocmd</span> <span style="color: #25BB4D;">BufRead</span> <span style="color: #000000;">*/</span>outlook<span style="color: #000000;">.</span>txt <span style="color: #000000;">:</span>source <span style="color: #000000;">$</span>HOME<span style="color: #000000;">/</span>vimfiles<span style="color: #000000;">/</span>mail<span style="color: #000000;">.</span>vim</pre></div></div>


<p>Here&#8217;s the script itself:</p>

<pre lang="">
#v::
SetTitleMatchMode, 2
IfWinActive, Message (Plain Text)
{
    WinGet, ActiveWindow, ID
    SendInput ^a
    Send ^c

    clipboard = %clipboard%

    FileDelete, %TEMP%\outlook.txt
    FileAppend, %Clipboard%, %TEMP%\outlook.txt

    RunWait, C:\Program Files\vim\vim72a\gvim.exe %TEMP%\outlook.txt

    FileRead, Clipboard, %TEMP%\outlook.txt

    WinActivate, ActiveWindow
    Send ^a^v^{HOME}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamesoff.net/site/2009/04/03/using-gvim-to-edit-mail-in-outlook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

