<?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>mntnoe.com &#187; Editors</title>
	<atom:link href="http://www.mntnoe.com/category/editors/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mntnoe.com</link>
	<description>Tips and tweaks making you more efficient with your favorite Linux tools.</description>
	<lastBuildDate>Sun, 16 May 2010 17:16:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Emacs-like incremental search in Vim</title>
		<link>http://www.mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/</link>
		<comments>http://www.mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 12:39:03 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=51</guid>
		<description><![CDATA[I like to be able to find the next occurence of a string without exiting the command line. Here is a hack to do that:
set incsearch
cnoremap &#60;expr&#62; / (getcmdtype() == '/' \&#124;\&#124; getcmdtype() == '?' ? (getcmdline() == '' ? "\&#60;Up&#62;" : "\&#60;Cr&#62;/\&#60;Up&#62;") : "/")
cnoremap &#60;expr&#62; ? (getcmdtype() == '/' \&#124;\&#124; getcmdtype() == '?' ? [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I like to be able to find the next occurence of a string without exiting the command line. Here is a hack to do that:</p>
<pre>set incsearch
cnoremap &lt;expr&gt; / (getcmdtype() == '/' \|\| getcmdtype() == '?' ? (getcmdline() == '' ? "\&lt;Up&gt;" : "\&lt;Cr&gt;/\&lt;Up&gt;") : "/")
cnoremap &lt;expr&gt; ? (getcmdtype() == '/' \|\| getcmdtype() == '?' ? (getcmdline() == '' ? "\&lt;Up&gt;" : "\&lt;Cr&gt;?\&lt;Up&gt;") : "?")</pre>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F&amp;t=Emacs-like%20incremental%20search%20in%20Vim" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Emacs-like%20incremental%20search%20in%20Vim%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F&amp;title=Emacs-like%20incremental%20search%20in%20Vim&amp;bodytext=I%20like%20to%20be%20able%20to%20find%20the%20next%20occurence%20of%20a%20string%20without%20exiting%20the%20command%20line.%20Here%20is%20a%20hack%20to%20do%20that%3A%0D%0Aset%20incsearch%0D%0Acnoremap%20%26lt%3Bexpr%26gt%3B%20%2F%20%28getcmdtype%28%29%20%3D%3D%20%27%2F%27%20%5C%7C%5C%7C%20getcmdtype%28%29%20%3D%3D%20%27%3F%27%20%3F%20%28getcmdline%28%29%20%3D%3D%20%27%27%20%3F%20%22%5C%26lt%3BUp%26gt%3B%22%20%3A%20%22%5C%26lt%3B" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F&amp;title=Emacs-like%20incremental%20search%20in%20Vim" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F&amp;title=Emacs-like%20incremental%20search%20in%20Vim&amp;notes=I%20like%20to%20be%20able%20to%20find%20the%20next%20occurence%20of%20a%20string%20without%20exiting%20the%20command%20line.%20Here%20is%20a%20hack%20to%20do%20that%3A%0D%0Aset%20incsearch%0D%0Acnoremap%20%26lt%3Bexpr%26gt%3B%20%2F%20%28getcmdtype%28%29%20%3D%3D%20%27%2F%27%20%5C%7C%5C%7C%20getcmdtype%28%29%20%3D%3D%20%27%3F%27%20%3F%20%28getcmdline%28%29%20%3D%3D%20%27%27%20%3F%20%22%5C%26lt%3BUp%26gt%3B%22%20%3A%20%22%5C%26lt%3B" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F07%2Femacs-like-incremental-search-in-vim%2F&amp;title=Emacs-like%20incremental%20search%20in%20Vim" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim config (May 2009)</title>
		<link>http://www.mntnoe.com/2009/05/vim-config-may-2009/</link>
		<comments>http://www.mntnoe.com/2009/05/vim-config-may-2009/#comments</comments>
		<pubDate>Fri, 22 May 2009 19:51:51 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[vimrc]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=49</guid>
		<description><![CDATA[Here is my Vim configuration as of May 2009. It is a work in progress (and will always be), and is designed on a number of pragmatical choices and compromises, rather than on a universal guideline.
That been said, I think my configuration has become pretty neat. See for yourself  
I only use Vim in [...]


Related posts:<ol><li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
<li><a href='http://www.mntnoe.com/2009/07/xmonad-config-july-2009/' rel='bookmark' title='Permanent Link: XMonad config (July 2009)'>XMonad config (July 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here is my Vim configuration as of May 2009. It is a work in progress (and will always be), and is designed on a number of pragmatical choices and compromises, rather than on a universal guideline.</p>
<p>That been said, I think my configuration has become pretty neat. See for yourself <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I only use Vim in the terminal, but most of the configuration also works in gVim (you may have to modify some of the bindings for the special characters like &lt;C-Space&gt;).</p>
<p>Although the .vimrc is long, I have tried to avoid making the configuration too heavy, so you will only find mappings that I actually use. Usually, I discover a work pattern that I want to speed up, and create a binding. Then I try it some time to see if I will get used to it; if not, I remove again. That&#8217;s the methodology <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Major features</h3>
<ul>
<li>Usable with both the <strong>Colemak</strong> and Qwerty layout</li>
<li>Readable<strong> colorscheme</strong></li>
<li>Makes heavy use of <strong>alt/meta</strong> bindings (as alt is easier to hit than control)</li>
<li>Efficient <strong>tabbed</strong> navigation</li>
<li>Custom <strong>status line</strong></li>
<li>Quick access to often used Ex commands</li>
<li>Many <strong>navigation improving bindings</strong> (examples: next occurence of visual selection, tag jump in new tab reusing existing tabs, search outline ({{{), open visual selection in split window)</li>
<li>Plugins are configured to be <strong>pervasive</strong> (they will not get in your way; at least not my way <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  )</li>
</ul>
<p>As of writing, I use these external plugins, which you may download from <a href="http://www.vim.org">vim.org</a>.</p>
<ul>
<li>AlignPlugin</li>
<li>NERD_commenter</li>
<li>a (alternate)</li>
<li>imaps</li>
<li>matchit</li>
<li>project</li>
<li>rhs (not yet published)</li>
<li>securemodelines</li>
<li>surround</li>
<li>taglist</li>
<li>timestamp</li>
<li>vcssvn</li>
</ul>
<p>Of &#8220;major&#8221; filetype plugins, I use haskellmode and latexsuite.</p>
<p>These are the files of interest. Enjoy <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li><a href="wp-content/uploads/2009/05/vimrc">.vimrc</a> (<a href="wp-content/uploads/2009/05/vimrc-unfolded.html">html</a>, <a href="wp-content/uploads/2009/05/vimrc-folded.html">html folded</a>)</li>
<li><a href="wp-content/uploads/2009/05/mntnoe.vim">colors/mntnoe.vim</a></li>
<li><a href="wp-content/uploads/2009/05/python.vim">ftplugin/python.vim</a></li>
<li><a href="wp-content/uploads/2009/05/java.vim">ftplugin/java.vim</a></li>
<li><a href="wp-content/uploads/2009/05/xml.vim">ftplugin/xml.vim</a></li>
<li><a href="wp-content/uploads/2009/05/c.vim">ftplugin/c.vim</a></li>
<li><a href="wp-content/uploads/2009/05/cpp.vim">ftplugin/cpp.vim</a></li>
<li><a href="wp-content/uploads/2009/05/cppindent.vim">ftplugin/cpp/cppindent.vim</a></li>
<li><a href="wp-content/uploads/2009/05/netrw.vim">ftplugin/netrw.vim</a></li>
<li><a href="wp-content/uploads/2009/05/tex.vim">ftplugin/tex.vim</a></li>
<li><a href="wp-content/uploads/2009/05/text.vim">syntax/text.vim</a></li>
</ul>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F&amp;t=Vim%20config%20%28May%202009%29" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Vim%20config%20%28May%202009%29%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F&amp;title=Vim%20config%20%28May%202009%29&amp;bodytext=Here%20is%20my%20Vim%20configuration%20as%20of%20May%202009.%20It%20is%20a%20work%20in%20progress%20%28and%20will%20always%20be%29%2C%20and%20is%20designed%20on%20a%20number%20of%20pragmatical%20choices%20and%20compromises%2C%20rather%20than%20on%20a%20universal%20guideline.%0D%0A%0D%0AThat%20been%20said%2C%20I%20think%20my%20configuration%20has%20beco" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F&amp;title=Vim%20config%20%28May%202009%29" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F&amp;title=Vim%20config%20%28May%202009%29&amp;notes=Here%20is%20my%20Vim%20configuration%20as%20of%20May%202009.%20It%20is%20a%20work%20in%20progress%20%28and%20will%20always%20be%29%2C%20and%20is%20designed%20on%20a%20number%20of%20pragmatical%20choices%20and%20compromises%2C%20rather%20than%20on%20a%20universal%20guideline.%0D%0A%0D%0AThat%20been%20said%2C%20I%20think%20my%20configuration%20has%20beco" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2009%2F05%2Fvim-config-may-2009%2F&amp;title=Vim%20config%20%28May%202009%29" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
<li><a href='http://www.mntnoe.com/2009/07/xmonad-config-july-2009/' rel='bookmark' title='Permanent Link: XMonad config (July 2009)'>XMonad config (July 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2009/05/vim-config-may-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using existing tabs when jumping to tags and files in Vim</title>
		<link>http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/</link>
		<comments>http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 13:24:56 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=34</guid>
		<description><![CDATA[Update: New version available. It is ported to native Vim Script, and support has been added for wildcards in &#38;path. Download. Add the file to your .vimrc, or fit it in as a plugin.
On March 27, 2008:
When you use the normal gf and &#60;C-]&#62; bindings, you change the buffer in the current window. There is [...]


Related posts:<ol><li><a href='http://www.mntnoe.com/2008/03/effective-use-of-tabs-in-vim/' rel='bookmark' title='Permanent Link: Effective use of Tabs in Vim'>Effective use of Tabs in Vim</a></li>
<li><a href='http://www.mntnoe.com/2009/05/vim-config-may-2009/' rel='bookmark' title='Permanent Link: Vim config (May 2009)'>Vim config (May 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff0000;">Update:</span></strong> New version available. It is ported to native Vim Script, and support has been added for wildcards in <em>&amp;path</em>. <a href="http://www.mntnoe.com/wp-content/uploads/2008/08/tabfind.vim">Download</a>. Add the file to your .vimrc, or fit it in as a plugin.</p>
<p><em>On March 27, 2008:</em></p>
<p>When you use the normal <em>gf</em> and <em>&lt;C-]&gt;</em> bindings, you change the buffer in the current window. There is also an option to create a new window when doing it, but there are no way to reuse windows that already show the corresponding buffer, at least not natively.</p>
<p>You can reuse tabs and windows (like other IDE&#8217;s) with <a title="findtab.py" href="http://www.mntnoe.com/wp-content/uploads/2008/03/findtab.py">findtab.py</a>, which is a simple Python script consisting of three functions. To use it, add something like the following to your .vimrc:</p>
<pre>pyfile ~/.vim/extern/findtab.py</pre>
<pre>nnoremap &lt;M-]&gt; :python TabTag()&lt;Cr&gt;
nnoremap &lt;C-w&gt;&lt;M-f&gt; :python TabFile()&lt;Cr&gt;</pre>
<p>I have tried to make <em>TabFile()</em> work like <em>gf</em>, supporting <em>path</em>, <em>includeexpr</em> and <em>suffixesadd</em>. I  think <em>TabTag()</em> works like <em>&lt;C-]&gt;</em>. The script also supplies a general Python function called <em>FindTag(filename)</em>. It works as you think&#8230;</p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F&amp;t=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F&amp;title=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim&amp;bodytext=Update%3A%20New%20version%20available.%20It%20is%20ported%20to%20native%20Vim%20Script%2C%20and%20support%20has%20been%20added%20for%20wildcards%20in%20%26amp%3Bpath.%20Download.%20Add%20the%20file%20to%20your%20.vimrc%2C%20or%20fit%20it%20in%20as%20a%20plugin.%0D%0A%0D%0AOn%20March%2027%2C%202008%3A%0D%0A%0D%0AWhen%20you%20use%20the%20normal%20gf%20and%20%26lt%3BC-%5D%26" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F&amp;title=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F&amp;title=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim&amp;notes=Update%3A%20New%20version%20available.%20It%20is%20ported%20to%20native%20Vim%20Script%2C%20and%20support%20has%20been%20added%20for%20wildcards%20in%20%26amp%3Bpath.%20Download.%20Add%20the%20file%20to%20your%20.vimrc%2C%20or%20fit%20it%20in%20as%20a%20plugin.%0D%0A%0D%0AOn%20March%2027%2C%202008%3A%0D%0A%0D%0AWhen%20you%20use%20the%20normal%20gf%20and%20%26lt%3BC-%5D%26" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F08%2Fusing-existing-tabs-when-jumping-to-tags-and-files-in-vim%2F&amp;title=Using%20existing%20tabs%20when%20jumping%20to%20tags%20and%20files%20in%20Vim" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.mntnoe.com/2008/03/effective-use-of-tabs-in-vim/' rel='bookmark' title='Permanent Link: Effective use of Tabs in Vim'>Effective use of Tabs in Vim</a></li>
<li><a href='http://www.mntnoe.com/2009/05/vim-config-may-2009/' rel='bookmark' title='Permanent Link: Vim config (May 2009)'>Vim config (May 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim C++ Indentation Hack</title>
		<link>http://www.mntnoe.com/2008/07/vim-c-indentation-hack/</link>
		<comments>http://www.mntnoe.com/2008/07/vim-c-indentation-hack/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 10:41:12 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=39</guid>
		<description><![CDATA[It is possible to customize the behavior of cindent in Vim by writing a wrapper function. All you need is to find out which indentifiers Vim uses for calculating the new indent, and then find an appropriate regular expression.
Suppose we do not want to indent stuff in namespace declarations. I found out that it is [...]


Related posts:<ol><li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It is possible to customize the behavior of <em>cindent</em> in Vim by writing a wrapper function. All you need is to find out which indentifiers Vim uses for calculating the new indent, and then find an appropriate regular expression.</p>
<p>Suppose we do not want to indent stuff in <em>namespace</em> declarations. I found out that it is enough to adjust the indentation of the first definition (except for a special case when using inheritance (&#8220;<em>: public &#8230;</em>&#8220;), see the code):<span id="more-39"></span></p>
<pre>setlocal nolisp
setlocal noautoindent

setlocal indentexpr=GetCppIndent(v:lnum)

if exists("*GetCppIndent")
    finish
endif

function! GetCppIndent(lnum)
    let cindent = cindent(a:lnum)
    if a:lnum == 1 | return cindent | endif

    let pattern1 = 'namespace\s\+\S\+\s*{\s*\%$'
    " pattern2 is used to match this case:
    " class c : public b
    "     { &lt;-- cursor
    let clspat = 'class\s\+\S\+\s*:\s*[^{]*'
    let pattern2 = 'namespace\s\+\S\+\s*{\s*'.clspat.'\%$'

    let lines = join(getline(max([ a:lnum - 10, 1]) , a:lnum-1), ' ')

    if  lines =~ pattern1
        return indent(CppFindOccurence('namespace', a:lnum))
    elseif  lines =~ pattern2 &amp;&amp; getline(a:lnum) =~ '^\s*{'
        return indent(CppFindOccurence('class', a:lnum))
    else
        return cindent
    endif
endfunction

function! CppFindOccurence(pattern, lnum)
    for line in range(a:lnum-1,a:lnum-10,-1)
        if getline(line) =~ a:pattern
            return line
        endif
    endfor
    return -1
endfunction</pre>
<p>Please note that this is a hack, and thus not perfect. For instance, it does not take comments or preprocessing directives into account, but that should be easy to implement if it is an issue for you&#8230;</p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F&amp;t=Vim%20C%2B%2B%20Indentation%20Hack" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Vim%20C%2B%2B%20Indentation%20Hack%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F&amp;title=Vim%20C%2B%2B%20Indentation%20Hack&amp;bodytext=It%20is%20possible%20to%20customize%20the%20behavior%20of%20cindent%20in%20Vim%20by%20writing%20a%20wrapper%20function.%20All%20you%20need%20is%20to%20find%20out%20which%20indentifiers%20Vim%20uses%20for%20calculating%20the%20new%20indent%2C%20and%20then%20find%20an%20appropriate%20regular%20expression.%0D%0A%0D%0ASuppose%20we%20do%20not%20wa" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F&amp;title=Vim%20C%2B%2B%20Indentation%20Hack" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F&amp;title=Vim%20C%2B%2B%20Indentation%20Hack&amp;notes=It%20is%20possible%20to%20customize%20the%20behavior%20of%20cindent%20in%20Vim%20by%20writing%20a%20wrapper%20function.%20All%20you%20need%20is%20to%20find%20out%20which%20indentifiers%20Vim%20uses%20for%20calculating%20the%20new%20indent%2C%20and%20then%20find%20an%20appropriate%20regular%20expression.%0D%0A%0D%0ASuppose%20we%20do%20not%20wa" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F07%2Fvim-c-indentation-hack%2F&amp;title=Vim%20C%2B%2B%20Indentation%20Hack" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/' rel='bookmark' title='Permanent Link: Split screen from visual mode in Vim'>Split screen from visual mode in Vim</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2008/07/vim-c-indentation-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split screen from visual mode in Vim</title>
		<link>http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/</link>
		<comments>http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/#comments</comments>
		<pubDate>Sun, 04 May 2008 00:30:43 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[split]]></category>
		<category><![CDATA[visual]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=36</guid>
		<description><![CDATA[I like to have a small window at the top of a tab page for reference. Useful when you want to consult the exact wording of a assignment or task description. This function creates a split with the top window showing the area of your visual mode selection. If more than one window is visible, [...]


Related posts:<ol><li><a href='http://www.mntnoe.com/2009/05/vim-config-may-2009/' rel='bookmark' title='Permanent Link: Vim config (May 2009)'>Vim config (May 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
<li><a href='http://www.mntnoe.com/2008/07/vim-c-indentation-hack/' rel='bookmark' title='Permanent Link: Vim C++ Indentation Hack'>Vim C++ Indentation Hack</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I like to have a small window at the top of a tab page for reference. Useful when you want to consult the exact wording of a assignment or task description. This function creates a split with the top window showing the area of your visual mode selection. <span style="text-decoration: line-through;">If more than one window is visible, it reuses the top most.</span> <em><span style="color: #800000;">Update (2008-06-18): The script now yields two windows: A &#8220;main&#8221; one, and the one showing only the selection.</span></em></p>
<p>Put something like this in your .vimrc:</p>
<pre>vnoremap &lt;M-s&gt; :&lt;C-u&gt;call VisualSplit()&lt;Cr&gt;

function! VisualSplit()
	let top = getpos("'&lt;")[1]
	let bot = getpos("'&gt;")[1]
	let height = bot - top + 1
	normal \&lt;Esc&gt;
	only
	split
	execute "1 wincmd w"
	" position and size the top window
	execute "normal '&lt;z" . height . "\&lt;Cr&gt;z\&lt;Cr&gt;"
	" return to 'main' window
	execute "normal \&lt;C-w&gt;2\&lt;C-w&gt;"
endfunction</pre>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F&amp;t=Split%20screen%20from%20visual%20mode%20in%20Vim" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Split%20screen%20from%20visual%20mode%20in%20Vim%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F&amp;title=Split%20screen%20from%20visual%20mode%20in%20Vim&amp;bodytext=I%20like%20to%20have%20a%20small%20window%20at%20the%20top%20of%20a%20tab%20page%20for%20reference.%20Useful%20when%20you%20want%20to%20consult%20the%20exact%20wording%20of%20a%20assignment%20or%20task%20description.%20This%20function%20creates%20a%20split%20with%20the%20top%20window%20showing%20the%20area%20of%20your%20visual%20mode%20select" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F&amp;title=Split%20screen%20from%20visual%20mode%20in%20Vim" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F&amp;title=Split%20screen%20from%20visual%20mode%20in%20Vim&amp;notes=I%20like%20to%20have%20a%20small%20window%20at%20the%20top%20of%20a%20tab%20page%20for%20reference.%20Useful%20when%20you%20want%20to%20consult%20the%20exact%20wording%20of%20a%20assignment%20or%20task%20description.%20This%20function%20creates%20a%20split%20with%20the%20top%20window%20showing%20the%20area%20of%20your%20visual%20mode%20select" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F05%2Fsplit-screen-from-visual-mode-in-vim%2F&amp;title=Split%20screen%20from%20visual%20mode%20in%20Vim" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.mntnoe.com/2009/05/vim-config-may-2009/' rel='bookmark' title='Permanent Link: Vim config (May 2009)'>Vim config (May 2009)</a></li>
<li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
<li><a href='http://www.mntnoe.com/2008/07/vim-c-indentation-hack/' rel='bookmark' title='Permanent Link: Vim C++ Indentation Hack'>Vim C++ Indentation Hack</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2008/05/split-screen-from-visual-mode-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Effective use of Tabs in Vim</title>
		<link>http://www.mntnoe.com/2008/03/effective-use-of-tabs-in-vim/</link>
		<comments>http://www.mntnoe.com/2008/03/effective-use-of-tabs-in-vim/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 20:58:25 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[tabs]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=31</guid>
		<description><![CDATA[This is a simple, but important tip:
Tabbed interfaces have emerged everywhere,  and also Vim 7 comes with support for it. For projects consisting of multiple files, I find it easier to work with tabs than with split windows and multiple buffers. Of course we need some better keybindings:
inoremap &#60;M-n&#62; &#60;C-o&#62;gt
inoremap &#60;M-p&#62; &#60;C-o&#62;gT
inoremap &#60;M-w&#62; &#60;Esc&#62;:tabclose&#60;Cr&#62;
inoremap [...]


Related posts:<ol><li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is a simple, but important tip:</p>
<p>Tabbed interfaces have emerged everywhere,  and also Vim 7 comes with support for it. For projects consisting of multiple files, I find it easier to work with tabs than with split windows and multiple buffers. Of course we need some better keybindings:</p>
<pre>inoremap &lt;M-n&gt; &lt;C-o&gt;gt
inoremap &lt;M-p&gt; &lt;C-o&gt;gT
inoremap &lt;M-w&gt; &lt;Esc&gt;:tabclose&lt;Cr&gt;
inoremap &lt;M-t&gt; &lt;Esc&gt;:tabe&lt;Cr&gt;</pre>
<pre>nnoremap &lt;M-n&gt; gt
nnoremap &lt;M-p&gt; gT
nnoremap &lt;M-w&gt; :tabclose&lt;Cr&gt;
nnoremap &lt;M-t&gt; :tabe&lt;Cr&gt;</pre>
<p>Also, making the tab bar always visible encourages you to use them more:</p>
<pre>set showtabline=2</pre>
<p>Now remember to use the -p parameter when you open Vim with multiple files:</p>
<pre>vim -p *.tex</pre>
<p>Having multiple files open in for instance LaTeX projects also allows you to use completion in  references to labels in the corresponding files.</p>
<p>BTW add colon and underscore to <em>iskeyword</em> to enable completion for labels like fig:nice_figure. Oh yes, and use <a href="http://vim-latex.sourceforge.net/">latex-suite</a>&#8230;</p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F&amp;t=Effective%20use%20of%20Tabs%20in%20Vim" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Effective%20use%20of%20Tabs%20in%20Vim%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F&amp;title=Effective%20use%20of%20Tabs%20in%20Vim&amp;bodytext=This%20is%20a%20simple%2C%20but%20important%20tip%3A%0D%0A%0D%0ATabbed%20interfaces%20have%20emerged%20everywhere%2C%20%20and%20also%20Vim%207%20comes%20with%20support%20for%20it.%20For%20projects%20consisting%20of%20multiple%20files%2C%20I%20find%20it%20easier%20to%20work%20with%20tabs%20than%20with%20split%20windows%20and%20multiple%20buffers.%20" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F&amp;title=Effective%20use%20of%20Tabs%20in%20Vim" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F&amp;title=Effective%20use%20of%20Tabs%20in%20Vim&amp;notes=This%20is%20a%20simple%2C%20but%20important%20tip%3A%0D%0A%0D%0ATabbed%20interfaces%20have%20emerged%20everywhere%2C%20%20and%20also%20Vim%207%20comes%20with%20support%20for%20it.%20For%20projects%20consisting%20of%20multiple%20files%2C%20I%20find%20it%20easier%20to%20work%20with%20tabs%20than%20with%20split%20windows%20and%20multiple%20buffers.%20" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F03%2Feffective-use-of-tabs-in-vim%2F&amp;title=Effective%20use%20of%20Tabs%20in%20Vim" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.mntnoe.com/2008/08/using-existing-tabs-when-jumping-to-tags-and-files-in-vim/' rel='bookmark' title='Permanent Link: Using existing tabs when jumping to tags and files in Vim'>Using existing tabs when jumping to tags and files in Vim</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2008/03/effective-use-of-tabs-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML editing and validation in VIM</title>
		<link>http://www.mntnoe.com/2008/02/xml-editing-and-validation-in-vim/</link>
		<comments>http://www.mntnoe.com/2008/02/xml-editing-and-validation-in-vim/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 23:29:01 +0000</pubDate>
		<dc:creator>mntnoe</dc:creator>
				<category><![CDATA[Editors]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml catalog]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=26</guid>
		<description><![CDATA[Taking a course in Web Technology, I suddenly found  myself editing a lot of XML files, so I hurried to fine-tune VIM to make editing more efficient. Please note that I am by no means an expert in XML, so please correct me, if I have misunderstood something. Configuration in  xml.vim. Features:

Tag closing [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Taking a course in Web Technology, I suddenly found  myself editing a lot of XML files, so I hurried to fine-tune VIM to make editing more efficient. Please note that I am by no means an expert in XML, so please correct me, if I have misunderstood something. Configuration in  <a title="xml.vim" href="http://www.mntnoe.com/wp-content/uploads/2008/02/xml.vim">xml.vim</a>. Features:</p>
<ul>
<li>Tag closing with code snippets from <a href="http://www.vim.org/scripts/script.php?script_id=301">xmledit</a>. Press <em>&lt;C-k&gt;</em> once to close the tag, and twice to close it and leave an empty line between.</li>
<li>Tag closing using omni-completion: <em>&lt;C-b&gt;</em>. This is used when the cursor is not at the end of the starting tag. Will insert the closing tag for the inner most unclosed starting tag.</li>
<li>Cycle between start and end tags with <em>&lt;LocalLeader&gt;5</em> (typically <em>\5</em> or <em>,5</em>)</li>
<li>Remove outer tag with <em>&lt;LL&gt;r</em></li>
<li>Goto parent tag with <em>&lt;LL&gt;u</em> (working on it, doesn&#8217;t work with  &lt;x/&gt; tags. Anybody got a clue how to do this correctly?)</li>
<li>Document pretty printing with <em>&lt;LL&gt;xf</em></li>
<li>Wellformedness checking (<em>&lt;LL&gt;xx</em>), DTD validation (<em>&lt;LL&gt;xd</em>) and XML Schema validation (<em>&lt;LL&gt;xs</em>) with XML Catalog support using xmllint (see below)</li>
</ul>
<p>Have a look at <a href="http://www.pinkjuice.com/howto/vimxml/index.xml">Vim as XML Editor</a> by Tobias Reif to find more tips.<span id="more-26"></span></p>
<h3>Validating using xmllint</h3>
<p>Tobias Reif&#8217;s howto shows a nice way of validating your document without saving them. The approach uses <a href="http://xmlsoft.org/xmllint.html">xmllint</a> from libxml2, which is very fast. It has xml catalog support, so it can translate <em>public</em>, <em>system</em> and <em>uri</em> identifiers to local files. Nice when you do not have to make changes in the document to validate it&#8230; Read the howto for further information, but in short, you have to:</p>
<ol>
<li>Specify the catalog files in .bashrc (xmllint and other validators reads (or should read) this environment variable).
<pre> export XML_CATALOG_FILES="$HOME/Docs/xml/catalog /etc/xml/catalog"</pre>
</li>
<li>Maintain a list of local schemas, and refer to them in the catalog files.
<pre>&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"&gt;
&lt;catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"&gt;
  &lt;group prefer="public" xml:base="file:///home/user/Docs/xml/schemas/"&gt;
    &lt;uri name="http://www.w3.org/2001/XMLSchema"
      uri="xmlschema/1_0/xsd/XMLSchema.xsd" /&gt;
  ...
  &lt;/group&gt;
&lt;/catalog&gt;</pre>
</li>
<li>Make xmllint know which schema to use. For DTD it is easy, as xmllint can find it from the DOCTYPE declaration in the document, and then resolve the schema from the catalog. See <a title="xml.vim" href="http://www.mntnoe.com/wp-content/uploads/2008/02/xml.vim">xml.vim</a> for how to do that in VIM. Unfortunately, it is not that easy with XML Schemas. xmllint can&#8217;t use the URI&#8217;s from the document namespace declaration,  nor can it use the reference in the schemaLocation attribute, so we cannot take advantage of catalog resolution here. If you know a validator that can do this, please let me know, as I couldn&#8217;t find one. However, I decided that I couldn&#8217;t live without this feature <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  , so I made a workaround, though a bit clumsy (see below).</li>
</ol>
<h3>XML Schema workaround</h3>
<p>To add support for xml catalog resolution, we need to implement it ourselves. I have written a simple URI resolver (<a title="ResolveURI" href="http://www.mntnoe.com/wp-content/uploads/2008/02/resolveuri.java">ResolveURI.java</a>) using the <a href="http://xml.apache.org/commons/components/resolver/">Apache XML Resolver</a> classes. It prints the resolved local URL to stdout if it can find an <em>uri</em> entry in the catalogs, or returns the argument if it can&#8217;t. To get quick access to it, we wrap it in a shell script:</p>
<pre>#!/bin/bash
DIR=/path/to/resolveruri
java -cp $DIR/resolver.jar:$DIR ResolveURI $@</pre>
<p>Normally, the Resolver classes expect the catalogs to be in a properties file, but as we use  XML_CATALOG_FILES instead, we put the file CatalogManager.properties in the class path, containing just the word</p>
<pre>catalogs=</pre>
<p>Now we should be ready to do at least catalog URI resolving manually. Try to run the shell script with an URI like <em>http://www.w3.org/2001/XMLSchema</em> as argument.</p>
<p>The only thing left is to make VIM call the validator. We can specify the document namespace URI as the schema identifier, or use the reference from the schemaLocation attribute. In either case, it should be placed in the <em>&#8220;s</em> register. For namespaces, this could be done quickly by placing the cursor over the URI and typing <em>vi&#8221;"sy</em>. Then we call xmllint, with the resolved Schema file:</p>
<pre>execute "%w !xmllint --noout --schema `resolveuri " . @s . "` -"</pre>
<p>It works with multiple namespaces, as long as they are <em>import</em>ed into the main Schema file, with the schemaLocation attribute is specified. I admit this solution is not particularly elegant, so if you know a better solution, please let me know. Although xmllint has limited support for XML Schema, at least you can now take advantage of it&#8217;s decent speed&#8230; Perhaps one should implement the URI resolver in C++, and without utilizing libraries to catch up with xmllint? Anyway, enjoy <img src='http://www.mntnoe.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p align="center"><a title="vim-xml.tar.bz2" rel="attachment wp-att-29" href="http://www.mntnoe.com/2008/02/xml-editing-and-validation-in-vim/vim-xmltarbz2/">Download tar.bz2 </a></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F&amp;t=XML%20editing%20and%20validation%20in%20VIM" title="Facebook"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=XML%20editing%20and%20validation%20in%20VIM%20-%20http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F" title="Twitter"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F&amp;title=XML%20editing%20and%20validation%20in%20VIM&amp;bodytext=Taking%20a%20course%20in%20Web%20Technology%2C%20I%20suddenly%20found%20%20myself%20editing%20a%20lot%20of%20XML%20files%2C%20so%20I%20hurried%20to%20fine-tune%20VIM%20to%20make%20editing%20more%20efficient.%20Please%20note%20that%20I%20am%20by%20no%20means%20an%20expert%20in%20XML%2C%20so%20please%20correct%20me%2C%20if%20I%20have%20misunderstood%20so" title="Digg"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F&amp;title=XML%20editing%20and%20validation%20in%20VIM" title="Reddit"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F&amp;title=XML%20editing%20and%20validation%20in%20VIM&amp;notes=Taking%20a%20course%20in%20Web%20Technology%2C%20I%20suddenly%20found%20%20myself%20editing%20a%20lot%20of%20XML%20files%2C%20so%20I%20hurried%20to%20fine-tune%20VIM%20to%20make%20editing%20more%20efficient.%20Please%20note%20that%20I%20am%20by%20no%20means%20an%20expert%20in%20XML%2C%20so%20please%20correct%20me%2C%20if%20I%20have%20misunderstood%20so" title="del.icio.us"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.mntnoe.com%2F2008%2F02%2Fxml-editing-and-validation-in-vim%2F&amp;title=XML%20editing%20and%20validation%20in%20VIM" title="StumbleUpon"><img src="http://www.mntnoe.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.mntnoe.com/2008/02/xml-editing-and-validation-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
