<?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; vim</title>
	<atom:link href="http://jamesoff.net/site/tag/vim/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>
		<item>
		<title>vim as a man-page reader</title>
		<link>http://jamesoff.net/site/2008/03/06/vim-as-a-man-page-reader/</link>
		<comments>http://jamesoff.net/site/2008/03/06/vim-as-a-man-page-reader/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 16:56:09 +0000</pubDate>
		<dc:creator>jamesoff</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://jamesoff.net/site/2008/03/06/vim-as-a-man-page-reader/</guid>
		<description><![CDATA[Sure, why not :) This goes in your zshrc: vman&#40;&#41; &#123; if &#91; $# -eq 0 &#93;; then /usr/bin/man else if man -w $* &#62;/dev/null 2&#62;/dev/null then /usr/bin/man $* &#124; col -b &#124; vim -c 'set ft=man nomod' - else echo No man page for $* fi fi &#125; alias man='vman' And this goes in [...]]]></description>
			<content:encoded><![CDATA[<p>Sure, why not :)</p>

<p>This goes in your zshrc:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">  vman<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span>
    <span style="color: #000000; font-weight: bold;">else</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #660033;">-w</span> <span style="color: #007800;">$*</span> <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
      <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #007800;">$*</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">col</span> <span style="color: #660033;">-b</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'set ft=man nomod'</span> -
      <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> No <span style="color: #c20cb9; font-weight: bold;">man</span> page <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #007800;">$*</span>
      <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">man</span>=<span style="color: #ff0000;">'vman'</span></pre></div></div>


<p>And this goes in your vimrc (in a suitable <code>augroup</code>):</p>

<pre lang="">
  autocmd FileType man setlocal ro nonumber nolist fdm=indent fdn=2 sw=4 foldlevel=2 | nmap q :quit<CR>
</pre>

<p>Now you&#8217;ll get nicely highlighted man pages with folded sections, and you can hit <code>q</code> to quit just like <code>less</code>.</p>

<p><img src='http://jamesoff.net/site/wp-content/uploads/2008/03/vim-manpage.png' alt='Vim as a manpage viewer' /></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesoff.net/site/2008/03/06/vim-as-a-man-page-reader/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

