<?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>Rob Rosenbaum's Development Blog &#187; Vim</title>
	<atom:link href="http://robrosenbaum.com/tags/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://robrosenbaum.com</link>
	<description>PHP, Symfony, and Other Web Things</description>
	<lastBuildDate>Wed, 30 Jan 2008 02:38:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mapping Tab to Both Snippets and Code Completion in Vim</title>
		<link>http://robrosenbaum.com/vim/mapping-tab-to-both-snippets-and-code-completion-in-vim/</link>
		<comments>http://robrosenbaum.com/vim/mapping-tab-to-both-snippets-and-code-completion-in-vim/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 01:10:15 +0000</pubDate>
		<dc:creator>Rob Rosenbaum</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://robrosenbaum.com/vim/mapping-tab-to-both-snippets-and-code-completion-in-vim/</guid>
		<description><![CDATA[SnippetsEmu allows you to create TextMate-style snippets in Vim which, together with Vim's native code-completion feature, makes Vim a top choice among lightweight text editors. When I installed Snippy (as its creator, ironically, likes to call it), I had one problem: SnippetsEmu maps its functionality to the &#60;Tab&#62; key, which is what I map code [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vim.org/scripts/script.php?script_id=1318">SnippetsEmu</a> allows you to create <a href="http://www.macromates.com/">TextMate</a>-style snippets in Vim which, together with Vim's native code-completion feature, makes Vim a top choice among lightweight text editors. When I installed Snippy (as its creator, ironically, likes to call it), I had one problem: SnippetsEmu maps its functionality to the &lt;Tab&gt; key, which is what I map code completion to. Thus, my mapping was causing Snippy not to work. As I was not about to oppose years of bash-trained muscle memory by mapping completion to a different key, I decided to bite the bullet (that hurts, by the way) and try to edit the plugin's vim script. It turned out to be a very easy edit. Apparently the saints were smiling on me - or, at least, the patron saint of Not Having to Learn Vim Scripting. </p>
<ins><p>Note that if you are using the SuperTab script, support is built into SnippetsEmu. The following is for everyone not using that script who wants to map the tab key.</p></ins>
<p>Open snippetsEmu.vim and find the function <code class="vim">s:ReturnKey</code>. In my version, it's on line 627. This function gets called when no snippet is found; all it does is output the tab character (or whatever key the snippets are mapped to). We want this function to output Control-P instead, since that is Vim's native code-completion trigger. Find the line in <code class="vim">s:ReturnKey</code> that looks like this:</p>
<pre class="vim">
exe "return \"".substitute(g:snippetsEmu_key, '^&lt;', "\\\\&lt;","")."\""
</pre>
<p class="leadingnoindent">This line might have been changed in your version, so just find the line that seems to do the same thing - output <code class="vim">g:snippetsEmu_key</code>. Replace that line with this:</p>
<pre class="vim">
return "\&lt;c-p&gt;"
</pre>
<p class="leadingnoindent">That's it! If that doesn't work, all I know to do is pray. I suggest you pray to the patron saint of Damnit I Have to Learn Vim Scripting.</p>]]></content:encoded>
			<wfw:commentRss>http://robrosenbaum.com/vim/mapping-tab-to-both-snippets-and-code-completion-in-vim/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
