<?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>Everything old is new again &#187; vim</title>
	<atom:link href="http://www.svendtofte.com/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.svendtofte.com</link>
	<description>rantings &#38; scraps on code and web development</description>
	<lastBuildDate>Thu, 27 Aug 2009 22:38:34 +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>Vim stuff</title>
		<link>http://www.svendtofte.com/other/vim-stuff/</link>
		<comments>http://www.svendtofte.com/other/vim-stuff/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 22:38:34 +0000</pubDate>
		<dc:creator>Svend</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[remotedesktop]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.svendtofte.com/?p=302</guid>
		<description><![CDATA[Vim is a nice editor, but I never liked the way it handles files. Thankfully I recently found a great script, which adds great quick browsing capabilities to Vim, called lusty-explorer.vim. Since 7, Vim has supported not just it&#8217;s own homegrown (and honestly fairly bastardized language) called VimScript, but also it has included bindindgs for [...]]]></description>
			<content:encoded><![CDATA[<p>Vim is a nice editor, but I never liked the way it handles files. Thankfully I recently found a great script, which adds great quick browsing capabilities to Vim, called <a href="http://www.vim.org/scripts/script.php?script_id=1890">lusty-explorer.vim</a>. Since 7, Vim has supported not just it&#8217;s own homegrown (and honestly fairly bastardized language) called VimScript, but also it has included bindindgs for popoular scripting languages such as Ruby and Python, so extending this script with some extra functionality was a great way to see how Vims extensibility works. And with lusty-explorer written in Ruby, this was a nice chance to learn these new aspects of Vim.</p>
<p><span id="more-302"></span></p>
<p>Anyway, lusty-explorer adds quick ways to browse either the loaded buffers, or browse the filesystem, but doing both in a way which blows away the built-in directory browser in Vim. But the way I like to browse files is basicly with a &#8220;recently used&#8221; file list, which should include currently open files. So with some changes to the lusty-explorer script, it now has a great &#8220;recently used&#8221; explorer, which I find totally eliminates any need to check currently loaded buffers. Want to open a file you know you&#8217;ve opened recently? Just hit <code>&lt;leader&gt;lu</code>, and the last many files you opened are there, easy to get to. If the file is alredy open, Vim just switches to that buffer, just like if you had entered <code>:e <em>file</em></code>.</p>
<p>Get <a href="/wp-content/uploads/2009/08/lusty-explorer-mod.vim">lusty-explorer-mod.vim</a>.</p>
<h3>Remote Desktop, Consolas and ClearType, oh my</h3>
<p>Something else which I&#8217;ve found a need for, is a capability to detect when Vim is used in a remote desktop session. Since I spend maybe half of all my time working in a RD, where ClearType is usually disabled, that means that my preferred font, <a href="http://www.codinghorror.com/blog/archives/000969.html">Consolas</a> <a href="http://www.codinghorror.com/blog/archives/000356.html">looks like shit</a>. While not the same as having ClearType disabled, I found that the easiest way out was to check <a href="http://msdn.microsoft.com/en-us/library/ms724385%28VS.85%29.aspx">if the current session was via Remote Desktop</a> (look for the <code>SM_REMOTESESSION</code>.) Thankfully that&#8217;s pretty easy to check. Here&#8217;s a minuscule C program which does this.</p>
<pre>#include &lt;windows.h&gt;
#pragma comment(lib, "user32.lib")

int main(void) {
    if (GetSystemMetrics(SM_REMOTESESSION)) {
        printf("1");
    } else {
        printf("0");
    }
    return 0;
}</pre>
<p>The precompiled <a href="/wp-content/uploads/2009/08/remotesession32bit.exe">file here</a> is compiled for 32bit, on WinXP, but tested on 64bit 2008 Server as well, where it should work just fine, through the miracle of <a href="http://en.wikipedia.org/wiki/Windows_on_Windows" title="Not World of Warcraft damnit!">WOW</a>. You can use this small executable, by dropping it in the path of computers where you use Vim, and where you might also log in via Remote Desktop, and then you can tweak your _vimrc like this:</p>
<pre>if has("gui_running") " gvim is running
    if has('win32')
        set guifont=Consolas:h11:cANSI
        if system("remotesession") == "1"
            set guifont=Lucida_Console:h10:cANSI
        endif
    endif
endif</pre>
<p>Lets you get the best of both worlds, Consolas, when ClearType is (probably) present, and Lucida when not (Lucida Console is still fairly decent.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.svendtofte.com/other/vim-stuff/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
