<?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>ColonelPanic &#187; vim</title>
	<atom:link href="http://colonelpanic.net/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://colonelpanic.net</link>
	<description>Dumping our corps so you don&#039;t have to</description>
	<lastBuildDate>Mon, 30 Jan 2012 17:50:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Debugging PHP in Vim using VimDebugger</title>
		<link>http://colonelpanic.net/2010/08/debugging-php-in-vim-using-vimdebugger/</link>
		<comments>http://colonelpanic.net/2010/08/debugging-php-in-vim-using-vimdebugger/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 15:41:13 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[xdebug]]></category>

		<guid isPermaLink="false">http://colonelpanic.net/?p=298</guid>
		<description><![CDATA[Remote Debugging PHP from vim I&#8217;ve recently been using PHP a lot.  I&#8217;ve also been using VIM a lot.  So, it makes sense that I would start using the PHP remote debugger, right?  Well, the problem is (and don&#8217;t take this the wrong way), the php remote debugger plugin for vim was written in 2004, [...]]]></description>
			<content:encoded><![CDATA[<h2>Remote Debugging PHP from vim</h2>
<p>I&#8217;ve recently been using PHP a lot.  I&#8217;ve also been using VIM a lot.   So, it makes sense that I would start using the PHP remote debugger,  right?  Well, the problem is (and don&#8217;t take this the wrong way), the  php remote debugger plugin for vim was written in 2004, and there are a  few things missing from it.  So, being the overly-easily-amused  developer I am, I embarked on a quest to fix it.</p>
<p><span id="more-298"></span></p>
<h2>DBGp python library</h2>
<p>It didn&#8217;t take me long to realize that the python classes (vimscript  doesn&#8217;t do sockets, so you have to use something like python) provided  with the old plugin was not extensible enough for what I needed.  I  started re-factoring it, but fortunately before I got too far I found a  DBGp python library written by ActiveState.  I had to do some hacking to  get it all working together &#8212; vim doesn&#8217;t deal with import statements  in python well &#8212; but it turned out to be perfect for my needs.</p>
<h2>VimDebugger README</h2>
<p>Here is the README from the <a title="VimDebugger" href="http://github.com/taxilian/VimDebugger">github repo</a>:</p>
<div>
<h3>Vim Debugger</h3>
<p>VimDebugger is a dbgp client plugin for vim for debugging php   applications with xdebug.  It is currently in early stages, but is   already much more advanced than many other options.</p>
<h3>Special Thanks</h3>
<p>VimDebugger utilizes the ActiveState DBGp library. VimDebugger borrows code liberally from <a href="http://www.vim.org/scripts/script.php?script_id=1152">the remote PHP debugger</a> vim plugin by Seung Woo Shin.</p>
<h3>Setup</h3>
<p>At present, VimDebugger.py must be saved as   $VIMRUNTIME.&#8221;/plugin/VimDebugger.py&#8221; in order to work correctly.  I hope   to allow more flexible placement of this file in a future release.    VimDebugger.vim should generally be placed in the same directory.</p>
<h3>Remote Debugging</h3>
<p>VimDebugger will listen on localhost:9000.  This could be changed in   VimDebugger.vim, but currently is not easily configurable through your   .vimrc.  You need to have xdebug already configured to connect to that   port.</p>
<h3>Debugger functions</h3>
<p>The following commands are added by the debugger for all your remote debugging needs:</p>
<ul>
<li>:DbgRun  &#8211; Starts the listener (listens for 10 seconds) if your  script is not  already attached.  If it is, continues (will run to the  end or until  the next breakpoint)</li>
<li>:DbgDetach &#8211; Detaches the remote debugger and shuts down the listener</li>
<li>:DbgToggleBreakpoint &#8211; Toggles a breakpoint on the current line of the current file</li>
<li>:DbgStepInto &#8211; Steps into the next function or include</li>
<li>:DbgStepOver &#8211; Steps over the next function or include</li>
<li>:DbgStepOut &#8211; Steps out to the next step up in the stack</li>
</ul>
<h3>Key Bindings</h3>
<p>The debugger does not automatically bind any hotkeys, but leaves  that  to you to do in your own .vimrc.  I often use Visual Studio, so I  set  my key bindings up in a similar way:</p>
<pre>map &lt;F11&gt; :DbgStepInto&lt;CR&gt;
map &lt;F10&gt; :DbgStepOver&lt;CR&gt;
map &lt;S-F11&gt; :DbgStepOut&lt;CR&gt;
map &lt;F5&gt; :DbgRun&lt;CR&gt;
map &lt;S-F5&gt; :DbgDetach&lt;CR&gt;
map &lt;F8&gt; :DbgToggleBreakpoint&lt;CR&gt;</pre>
<h3>Watch</h3>
<p>Currently, there are no functions for adding your own watch items,   but that is planned for one of the next releases.  For now, the watch   window will automatically refresh every step with the current context.    The Watch window utilizes vim code folding on multi-line entries, so if   you have an object, be sure to expand it by double clicking, hitting   enter, or using the vim code folding keyboard commands to see the   introspection at work.  Only three levels are returned, to keep the   response from overwhelming the debugger.</p>
<p>For objects, a list of  the methods available on that object will be  returned with their  visibility.  Also, a list of properties will be  returned with their  visibility and their value.</p>
<p>For arrays, a list of values (up to three nested levels) will be returned.</p>
<h3>Stack</h3>
<p>The stack window updates every frame. To go to another part of the   stack, simply go to the line in question and double click or press   enter.</p>
<h2>Screenshots</h2>
<p>How well does it work?  Well, let me show you some screenshots, and then you decide.</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-8.39.21-AM2.png"><img class="alignnone size-full wp-image-301" title="Screen shot 2010-08-05 at 8.39.21 AM" src="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-8.39.21-AM2.png" alt="" width="586" height="209" /></a></p>
<p>On the left, you see the code window; that looks almost identical to the old vim plugin.  That&#8217;s one thing it did very well, and I couldn&#8217;t improve on it; so I shamelessly stole a lot of the code, instead.  On the bottom right you see the first of the improvements I added.  Instead of just displaying a list of stack entries and requiring someone to type &#8220;:Up&#8221; and &#8220;:Dn&#8221; to traverse the stack, the list is formatted and set up so that you can double click or press enter on the line you want, and it will take you there in the left pane.</p>
<p>The real improvements can be seen in the watch window, on the top right.  You may notice that these are folded; there are three variables in the local scope, and as you can see they are all instances of objects.  Well, often when I&#8217;m debugging I need to know what kind of object that is!  Here it tells you.  That&#8217;s not even the best part, though; expand the fold, and you&#8217;ll see the following:</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.01.06-AM.png"><img class="alignnone size-full wp-image-302" title="Screen shot 2010-08-05 at 9.01.06 AM" src="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.01.06-AM.png" alt="" width="473" height="71" /></a></p>
<p>The number of methods and properties!  Expand methods:</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.06.29-AM.png"><img class="alignnone size-full wp-image-303" title="Screen shot 2010-08-05 at 9.06.29 AM" src="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.06.29-AM.png" alt="" width="441" height="152" /></a></p>
<p>I&#8217;ve truncated it for brevity, but trust me: the method names are all there.  Let&#8217;s look at properties.</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.07.34-AM.png"><img class="alignnone size-full wp-image-304" title="Screen shot 2010-08-05 at 9.07.34 AM" src="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.07.34-AM.png" alt="" width="444" height="182" /></a></p>
<p>You&#8217;ll notice again; all of the properties, with their values, and&#8230; more folds?  Open one of them.</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.11.00-AM.png"><img class="alignnone size-full wp-image-305" title="Screen shot 2010-08-05 at 9.11.00 AM" src="http://colonelpanic.net/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-9.11.00-AM.png" alt="" width="610" height="187" /></a></p>
<p>As you can see, array values are also sent.  For practical reasons, there is a depth limit of 3 when fetching watch variables, but that is configurable.  The main challenge is getting the data back from PHP; I have the max data size set at 64KB, so that is the limit to how much can be sent. We could probably raise that limit, but that has other consequences.</p>
<h2>Installing it</h2>
<p>First, you may want to read <a title="How to debug PHP with Vim and XDebug" href="http://tech.blog.box.net/2007/06/20/how-to-debug-php-with-vim-and-xdebug-on-linux/" target="_blank">this blog post</a> to see how to set up xdebug.  Instead of using the vim plugin they link to, though, get mine from the <a title="VimDebugger on github" href="http://github.com/taxilian/VimDebugger">github repo</a>.  Put VimDebugger.py and VimDebugger.vim in your ~/.vim/plugins dir, and add the key bindings to your .vimrc.  Let me know how it goes!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://colonelpanic.net/2010/08/debugging-php-in-vim-using-vimdebugger/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Terminal Nirvana on Snow Leopard with SIMBL + Visor</title>
		<link>http://colonelpanic.net/2010/07/terminal-nirvana-on-snow-leopard-with-simbl-visor/</link>
		<comments>http://colonelpanic.net/2010/07/terminal-nirvana-on-snow-leopard-with-simbl-visor/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 15:09:24 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Systems Administration]]></category>
		<category><![CDATA[end]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[simbl]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[visor]]></category>

		<guid isPermaLink="false">http://colonelpanic.net/?p=255</guid>
		<description><![CDATA[Note 1: The method described here should also work in Mac OS X Leopard or Tiger, just get the appropriate versions of SIMBL / Visor. Note 2: If you don&#8217;t want everything on my bullet list, just follow the steps appropriate for what you want to accomplish. Note 3: I have provided .patch files, etc. [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em><strong>Note 1</strong>: The method described here should also work in Mac OS X Leopard or Tiger, just get the appropriate versions of SIMBL / Visor.</em><br />
<em><strong>Note 2</strong>: If you don&#8217;t want everything on my bullet list, just follow the steps appropriate for what you want to accomplish.</em><br />
<em><strong>Note 3</strong>: I have provided .patch files, etc. at the bottom of the post for those who, like me, are a bit lazy.</em></p></blockquote>
<h2>What is Terminal Nirvana?</h2>
<p>As a developer, Terminal is one of my best friends. Maybe you can relate. I have constantly been in search of the ultimate Terminal configuration, and it has ever eluded me&#8230; until now.</p>
<p>But what is Terminal Nirvana? Here are my criteria:</p>
<ol>
<li><strong>I want the Home / End keys to move the cursor to the front / end of the line. </strong>I grew up on Windows, and I like the keys to function this way. To me, it just makes sense. Unfortunately, <a title="KeyFixer" href="http://www.starryhope.com/tech/apple/2006/keyfixer/">KeyFixer</a> doesn&#8217;t work in Terminal (but I highly recommend it for changing the behavior in most other apps!).</li>
<li><strong>I don&#8217;t want Home / End to behave differently when I am in a <a title="GNU Screen" href="http://en.wikipedia.org/wiki/Gnu_screen">screen</a> session.</strong> I use screen all the time, and Home / End need to behave consistently.</li>
<li><strong>I don&#8217;t want Home / End to do unexpected things in </strong><strong><a href="http://en.wikipedia.org/wiki/Vim_(text_editor)">VIM</a> &#8211; ever</strong><strong>.</strong> Pressing Home / End in VIM should, at the very least, not do weird things like delete lines, whether I am in a screen session or not.</li>
<li><strong>I want my terminal window available at all times.</strong> With as much as I use the terminal, opening Terminal.app all the time feels wasteful. There should be a better way. This is where <a title="SIMBL" href="http://www.culater.net/software/SIMBL/SIMBL.php">SIMBL</a> and <a title="Visor" href="http://visor.binaryage.com/">Visor</a> come in.</li>
<li><strong>I don&#8217;t want it to show up in the Dock, or in my Command + Tab list.</strong> As useful as Terminal is, there are a lot of other useful applications around, and I use a lot of them. Since I always want Terminal open anyway, it is annoying to constantly avoid / ignore / tab over it when I am using Command + Tab to switch to another running application. Oh, and it should stay away from my Dock, too.</li>
<li><strong>I want good, configurable colors in my shell.</strong> Fortunately, Visor takes care of this one by including <a title="Terminal Colors in Leopard / Snow Leopard" href="http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal">TerminalColours</a> as part of the package, so you get this one &#8220;for free.&#8221;</li>
</ol>
<p>Sound like a tall order? It took me a few hours crawling around the web and experimenting to come up with a good solution, but I managed it in the end. Hopefully my experience can help save a few people some time in the future.</p>
<p>This is how I did it.<br />
<span id="more-255"></span></p>
<h2>First things first</h2>
<p>Before you go any further, make sure you have installed <a title="SIMBL" href="http://www.culater.net/software/SIMBL/SIMBL.php">SIMBL</a> and <a title="Visor" href="http://visor.binaryage.com/">Visor</a>. The latest versions work great in Snow Leopard with a 64-bit Terminal.app, so knock yourself out.</p>
<h2>Home / End keys</h2>
<p>To change the Home / End keys in Terminal.app, you are going to need to go to Terminal -&gt; Preferences -&gt; [Settings] -&gt; [Keyboard]. Remember, settings are profile-specific, so you will need to make the changes to any profiles you care about. (<em>Note: Visor uses the &#8220;Visor&#8221; profile, regardless of what you set as your default profile. What I do is rename the automatically-created &#8220;Visor&#8221; profile, configure my default profile, and then duplicate it with the name &#8220;Visor&#8221;.</em>)</p>
<p>The first thing I tried was changing the keybindings to &#8220;\001&#8243; and &#8220;\005&#8243; per the instructions I found on <a href="http://www.rickycampbell.com/fix-osx-terminal-pgup-pgdn-home-and-end/">Ricky Campbell&#8217;s blog</a>. This seemed to make sense; CTRL+A and CTRL+E move the cursor to the front / end of the line in Terminal. And I thought it was working perfectly, for a few glorious moments&#8230;</p>
<p>Unfortunately, CTRL+A is also the key combination to start a command in screen. So when I launched screen, suddenly my home key didn&#8217;t work anymore, and I randomly started sending screen commands when I used it.</p>
<p>I also tried using a ~/.inputrc file and the keybindings &#8220;\033[1~&#8221; and &#8220;\033[4~&#8221; as discussed on <a href="http://fplanque.com/dev/mac/mac-osx-terminal-page-up-down-home-end-of-line">two</a> <a href="http://linuxart.com/log/archives/2005/10/13/super-useful-inputrc/">blogs</a> I stumbled across while looking for an alternate solution. Now, I really thought I had the problem licked. Except, Home / End did weird things in VIM running within a screen session, and the necessity of using an additional .inputrc file was just a bit of a bummer.</p>
<p>Turns out Shift + Home and Shift + End  already did what I wanted, so the simplest solution of all is to just copy those keybindings already present in the Terminal settings. For good measure, I copied the &#8220;shift page up&#8221; and &#8220;shift page down&#8221; bindings to &#8220;page up&#8221; and &#8220;page down.&#8221; (<em>Note: you can either copy-paste the existing values, or hit ESC to get the \033 value and then type the other characters manually.</em>)</p>
<h3>Terminal key bindings:</h3>
<ul>
<li>home
<ul>
<li>Value: \033[H</li>
</ul>
</li>
<li>end
<ul>
<li>Value: \033[F</li>
</ul>
</li>
<li>page up
<ul>
<li>Value: \033[5~</li>
</ul>
</li>
<li>page down
<ul>
<li>Value: \033[6~</li>
</ul>
</li>
</ul>
<h2>Fixing VIM in screen</h2>
<p>Okay, almost there with the keybindings. If you run VIM inside a screen session, you will notice that Home deletes the current line, and using the arrow keys while in insert mode inserts A / B / C / D rather than moving the cursor. Not good.</p>
<p>A little tweak to your existing ~/.vimrc file will fix it right up (or, if you don&#8217;t have an existing ~/.vimrc, create it). (<em>Note: the easiest way to get the proper escape characters is to enter insert mode, and hit CTRL+V followed by the Home or End key. This will add the ^[ escape character, as well as the [F or [H characters. Do the same thing for CTRL + O to get the ^O escape character.</em>) By using CTRL+O on the imap lines, we make the Home / End keys work the same way in insert mode or command mode.</p>
<p>As an added bonus, this fixes the arrow keys while in insert mode. Though, to be honest, I have no idea why&#8230;</p>
<div class="wp_syntax">
<div class="code">
<pre class="vim" style="font-family:monospace;"><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #adadad; font-style: italic;">&quot; ~/.vimrc</span>
&nbsp;
<span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #adadad; font-style: italic;">&quot; Fix home and end keybindings for screen</span>
<span style="color: #804040;">map</span> <span style="color: #000000;">^</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#91;</span>F <span style="color: #000000;">$</span>
imap <span style="color: #000000;">^</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#91;</span>F <span style="color: #000000;">^</span>O<span style="color: #000000;">$</span>
<span style="color: #804040;">map</span> <span style="color: #000000;">^</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#91;</span>H g0
imap <span style="color: #000000;">^</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#91;</span>H <span style="color: #000000;">^</span>Og0</pre>
</div>
</div>
<h2>Making Terminal always available</h2>
<p>This one was actually pretty simple. Using <a title="SIMBL" href="http://www.culater.net/software/SIMBL/SIMBL.php">SIMBL</a> and <a title="Visor" href="http://visor.binaryage.com/">Visor</a> (both compatible with 64-bit Terminal at the time of this writing) you can get Terminal to dock to the top / side / bottom of your screen, and configure it to open with a keystroke you can define.</p>
<p>My keystroke is Command + Esc (turn off Front Row first, if you hate it as much as I do). Once Terminal has been launched for the first time (thus creating the Visor window), this keystroke gets you in from anywhere, or hides it when you are done.</p>
<h2>Hiding the Dock icon, and removing Terminal from the Command + Tab list</h2>
<p>This is the most involved step, but it also provides one of the biggest benefits in my mind. Most of the information here comes from a <a href="http://www.metaskills.net/2009/8/18/visor-terminal-on-snow-leopard">MetaSkills blog article</a>.</p>
<p>In order to accomplish this, the LSUIElement key in Terminal&#8217;s Info.plist must be set to &#8220;1&#8243;. This disables the Dock icon and removes the application from the Command + Tab list. Don&#8217;t want to completely prevent Terminal from ever functioning like a normal application? The quick solution is to create new application &#8220;VisorTerminal.app&#8221; which is used for Visor, while leaving Terminal.app alone to function as normal. (This is actually a good thing, because another side-effect of setting LSUIElement : 1 is you no longer have anything change in the menubar when you are in your application&#8230; ie, you can&#8217;t click on VisorTerminal next to the Apple icon, and go into Preferences.)</p>
<h3>Create a new VisorTerminal.app</h3>
<p>Duplicate the existing Terminal.app.</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Utilities<span style="color: #000000; font-weight: bold;">/</span>Terminal.app <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Utilities<span style="color: #000000; font-weight: bold;">/</span>VisorTerminal.app</pre>
</div>
</div>
<p>Once you have duplicated Terminal.app, you need to change a few bundle identifiers in your new application so the two appear as distinct entities to Mac OS X. In other words, change &#8220;Terminal&#8221; to &#8220;VisorTerminal&#8221; in a few places. This is also when you add LSUIElements : 1.</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- /Applications/Utilities/VisorTerminal.app/Contents/Info.plist --&gt;</span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CFBundleDisplayName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>VisorTerminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CFBundleIdentifier<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.apple.VisorTerminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CFBundleName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>VisorTerminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #808080; font-style: italic;">&lt;!-- Note: Put this right before the closing &lt;/dict&gt;&lt;/plist&gt;</span>
<span style="color: #808080; font-style: italic;">     at the end of the file --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>LSUIElement<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...</pre>
</div>
</div>
<p>At this point, rather than entering my preferences all over again, I elected to copy my Terminal.app preferences. Repeat this step any time you make preference changes that you want to copy over. (<em>Note: using a symlink does not seem to work. If you make changes while in VisorTerminal, such as changing the Visor hotkey, the modified file is saved over your symlink.</em>)</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Preferences<span style="color: #000000; font-weight: bold;">/</span>com.apple.Terminal.plist ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Preferences<span style="color: #000000; font-weight: bold;">/</span>com.apple.VisorTerminal.plist</pre>
</div>
</div>
<h3>Modify Visor to use VisorTerminal.app</h3>
<p>Once your new application is created and ready to go, you need to tell Visor to activate for that application rather than Terminal.app. Apply the following very familiar tweaks to Visor&#8217;s Info.plist:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- ~/Library/Application\ Support/SIMBL/Plugins/Visor.bundle/Contents/Info.plist --&gt;</span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>BundleIdentifier<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.apple.VisorTerminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ExecPattern<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>*/VisorTerminal.app/Contents/MacOS/Terminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>BundleIdentifier<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.apple.VisorTerminal<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...</pre>
</div>
</div>
<p>Once this last step is done, you are almost there. Make sure Terminal.app and VisorTerminal.app are both closed. Now, launch VisorTerminal.app and behold its wonder!</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">open <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Utilities<span style="color: #000000; font-weight: bold;">/</span>VisorTerminal.app</pre>
</div>
</div>
<h2>What? It didn&#8217;t work?</h2>
<p>Let me guess. A Terminal window opened, but Visor didn&#8217;t take effect. What gives? (You may have also noticed that you don&#8217;t have an entry in your menubar&#8230; see above.)</p>
<p>Turns out newer versions of SIMBL <a href="http://code.google.com/p/simbl/issues/detail?id=9">don&#8217;t activate in applications with LSUIElement : 1</a>. Apparently this is expected behavior due to the Cocoa event mechanism. But all is not lost!</p>
<p>You can manually inject SIMBL into an application using Apple Script.</p>
<div class="wp_syntax">
<div class="code">
<pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;VisorTerminal&quot;</span>
	inject SIMBL <span style="color: #0066ff;">into</span> Snow Leopard
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></pre>
</div>
</div>
<p>Great, but I don&#8217;t want to do something manually every time I want a Visor window. I just want it to always be there, remember?</p>
<p>Use the <a href="http://www.tuaw.com/2007/12/27/applescript-the-script-editor/">AppleScript Editor</a> to save this snippet as an application, and then include that application in your user startup items. Voila! When you log in, the AppleScript helper executes, which launches VisorTerminal with SIMBL injected. Visor activates, your terminal automatically hides itself, yet is always there when you want it with the push of a button. It doesn&#8217;t clutter up your Dock, your application switching, and you can still use Terminal.app as usual whenever it makes sense to do so.</p>
<h2>Final thoughts</h2>
<p>First off, note that this tutorial was written using <em>SIMBL 0.9.7a</em>, <em>Visor 2.2</em>, and <em>Terminal 2.1.1 (273)</em> on Mac OS X <em>Snow Leopard 10.6.4</em>. YMMV.</p>
<p>Secondly, my thanks to all the people who are smarter than me and figured all this out. All I did was put things together.</p>
<p>Third, see below for patch files and my AppleScript application.</p>
<p>Finally, does anyone have the following issue, and know a way around it? After setting my key bindings, when I launch Terminal for the first time, they don&#8217;t take effect. Home does nothing special. If I open a new Terminal window, the home key starts working as expected, both in the new window as well as the original window. This happens to me whether I use \001 for the control character (and this without a ~/.inputrc file) or if I use the solution described above. Slightly bothersome, but since I almost always use my Visor terminal (which doesn&#8217;t exhibit the same problem&#8230; nor did it using Visor sans any modifications discussed here) I don&#8217;t notice it too often.</p>
<p><strong>Patch files:</strong> <a href="http://gist.github.com/484082">http://gist.github.com/484082</a><br />
<strong>AppleScript app:</strong> <a href="http://colonelpanic.net/wp-content/uploads/2010/07/HiddenVisorTerminal.zip">HiddenVisorTerminal.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://colonelpanic.net/2010/07/terminal-nirvana-on-snow-leopard-with-simbl-visor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TextMate &#8220;Go to file&#8230;&#8221; in VIM</title>
		<link>http://colonelpanic.net/2010/05/textmate-go-to-file-in-vim/</link>
		<comments>http://colonelpanic.net/2010/05/textmate-go-to-file-in-vim/#comments</comments>
		<pubDate>Tue, 11 May 2010 20:21:02 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://colonelpanic.net/?p=194</guid>
		<description><![CDATA[Ahh, the great debate; which is the best text editor of them all?  I have used many of them, but I keep falling back to what for me is the classic one: VIM. Second to VIM, however, I have always been very impressed with TextMate. There are features in TextMate that just make me happy.  [...]]]></description>
			<content:encoded><![CDATA[<p>Ahh, the great debate; which is the best text editor of them all?  I have used many of them, but I keep falling back to what for me is the classic one: VIM.</p>
<p>Second to VIM, however, I have always been very impressed with TextMate. There are features in TextMate that just make me happy.  My favorate is the &#8220;Go to file&#8230;&#8221; option (Command-T).  For those of you who aren&#8217;t familiar with it, when you press Command-T in TextMate a little popup window appears.  You type part of the filename that you are looking for and TextMate displays all files in your project that contain that string.</p>
<p><span id="more-194"></span><a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.42.30-PM.png"><img class="size-medium wp-image-195 alignright" title="Screen shot 2010-05-11 at 1.42.30 PM" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.42.30-PM-300x214.png" alt="" width="186" height="132" /></a>In my (not so) humble opinion, this has got to be about the best project management tool that has ever been conceived.  The problem, however, is that TextMate only works on Mac!  Granted, I have in recent years migrated to where I do most of my work on a Mac, but when I find myself working on Windows or Linux, I need my text editor!  That&#8217;s where VIM comes in.</p>
<p>VIM is about the most extensible editor I&#8217;ve ever used, and that is one thing I love about it.  Granted, there are disadvantages to it &#8212; the learning curve is heavy, for one.  But, once you figure out how to do things, it&#8217;s great.  However, it definitely is missing this &#8220;Go to file&#8230;&#8221; like ability.  This has bothered me for months, but only today have I finally found an adequate solution.</p>
<p>The Plugin is called <a title="Fuzzy Finder" href="http://www.vim.org/scripts/script.php?script_id=1984" target="_blank">Fuzzy Finder</a>.  At first glance, it seems like it almost does what we need, but not quite.  However, combined with the <a title="VIM project plugin" href="http://www.vim.org/scripts/script.php?script_id=69">Project</a> plugin, you can come pretty darn close to TextMate&#8217;s &#8220;Go to file&#8230;&#8221; feature.</p>
<p>My purpose here isn&#8217;t to teach you how to use the project plugin, since there already exists <a title="Projects with Vim using projects.vim" href="http://nodnod.net/2009/feb/09/projects-vim-using-projectsvim/" target="_blank">plenty</a> <a title="Vimgrep and Vim Project" href="http://weierophinney.net/matthew/archives/194-Vimgrep-and-Vim-Project.html" target="_blank">of</a> <a title="VIM project plugin" href="http://www.vim.org/scripts/script.php?script_id=69" target="_blank">documentation</a>.   I will give you a few tips, however.</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.56.59-PM.png"><img class="alignright size-medium wp-image-196" title="vim project name of entry" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.56.59-PM-300x78.png" alt="" width="197" height="51" /></a>When you create an entry in your project list (\C), it asks you several questions:</p>
<ul>
<li>&#8220;Enter the name of the Entry:&#8221; &#8211; This can be any name you wish</li>
<li><a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.57.33-PM.png"><img class="alignright size-medium  wp-image-197" title="vim project dir to load" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.57.33-PM-300x75.png" alt="" width="233" height="58" /></a>&#8220;Enter the Absolute Directory to Load:&#8221; &#8211; This should be the root path for your project</li>
<li>&#8220;Enter the CD parameter:&#8221; &#8211; This is the most useful option for us, but probably the least understood.</li>
<li><a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.58.01-PM.png"><img class="alignright size-medium  wp-image-198" title="vim project CD param" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-1.58.01-PM-300x88.png" alt="" width="243" height="71" /></a>&#8220;Enter the File Filter: &#8221; &#8211; I usually leave this blank, but you can use it to select which files to find</li>
</ul>
<p>The trick that I have found is that if you specify the same path for the Absolute Directory and the CD parameter, when you open files in your project vim will use that as its CWD.</p>
<p><a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.05.14-PM.png"><img class="alignright size-medium wp-image-200" title="vim project screenshot" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.05.14-PM-300x191.png" alt="" width="300" height="191" /></a>So now we have a project and we can browse the files.  We can also do fast searches in the project pane; simply use &#8220;/&#8221; to search for filenames.  However, this still isn&#8217;t quite what we wanted.</p>
<p>The next step is to install the <a title="Fuzzy Finder" href="http://www.vim.org/scripts/script.php?script_id=1984" target="_blank">Fuzzy Finder</a> plugin. Fuzzy Finder is set up to let you quickly navigate a directory tree, but it also has some other unique features that make it ideal for what we want.  To open Fuzzy Finder to find a file, the command you want is &#8220;:FufFile&#8221;.  This will pull up the Fuzzy Finder mini-dialog.<a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.09.17-PM.png"><img class="alignright size-full wp-image-201" title="fuzzyfinder std" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.09.17-PM.png" alt="" width="139" height="88" /></a></p>
<p>However, this still isn&#8217;t quite what we want; it does let us navigate quickly with filters, but we want to quickly search through all files in the directory!  Well, as it turns out, FuzzyFinder supports wildcards; not just &#8220;*&#8221;, but also the less often seen &#8220;**&#8221;, which means &#8220;in all subdirectories&#8221;.  So, we can then do &#8220;:FufFile **/&#8221; to tell it to start searching there.</p>
<p>Depending on the size of your directory, this can be a bit slow &#8212; it&#8217;s not perfect.  However, you&#8217;ll find that this way you can very quickly search through your <a href="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.12.36-PM.png"><img class="alignright size-medium wp-image-202" title="fuzzyfinder recursive" src="http://colonelpanic.net/wp-content/uploads/2010/05/Screen-shot-2010-05-11-at-2.12.36-PM-300x166.png" alt="" width="300" height="166" /></a>files to open the one you want &#8212; almost the same way you would in TextMate.  Keep in mind that this relies on where our CWD is, so you can use VIM&#8217;s lcd command to move to the root of where you want to search.</p>
<p>Now, typing &#8220;:FufFile **/&#8221; all the time is a little cumbersome, so you may want to add a shortcut.  If you really want it to be just like textmate, you could probably set Meta-T to open it, but I prefer to leave that for MacVim which uses it to open tabs.  Instead, I use the following:</p>
<pre style="padding-left: 30px;">nmap &lt;leader&gt;ff :FufFile **/&lt;CR&gt;
</pre>
<p>In my configuration this means that I just have to type &#8220;\ff&#8221; to have Fuzzy Finder pop up so that I can quickly open the file I want.  I also map \fb to Fuzzy Finder&#8217;s buffer search to quickly switch to another file in the buffer (&#8220;nmap &lt;leader&gt;fb :FufBuffer&lt;CR&gt;&#8221;).</p>
<p>Anyway, I hope this helps someone!</p>
]]></content:encoded>
			<wfw:commentRss>http://colonelpanic.net/2010/05/textmate-go-to-file-in-vim/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

