<?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; vim</title>
	<atom:link href="http://mntnoe.com/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://mntnoe.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Sep 2011 07:19:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Being productive in GMail using ItsAllText</title>
		<link>http://mntnoe.com/2010/02/being-productive-in-gmail-using-itsalltext/</link>
		<comments>http://mntnoe.com/2010/02/being-productive-in-gmail-using-itsalltext/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 19:28:43 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</dc:creator>
				<category><![CDATA[Other Tips]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=108</guid>
		<description><![CDATA[GMail has a nice keyboard accelerated web interface making it competitive to desktop mail clients as Thunderbird and even Mutt. One reason I stayed with Mutt for a long time was the ability to integrate with Vim. I switched to GMail&#8217;s web interface for other reasons, but nevertheless it was delightful to discover ItsAllText; a [...]]]></description>
			<content:encoded><![CDATA[<p>GMail has a nice keyboard accelerated web interface making it competitive to desktop mail clients as Thunderbird and even Mutt. One reason I stayed with Mutt for a long time was the ability to integrate with Vim. I switched to GMail&#8217;s web interface for other reasons, but nevertheless it was delightful to discover <a href="https://addons.mozilla.org/en-US/firefox/addon/4125">ItsAllText</a>; a Firefox add-on that allows you to edit any <em>textarea</em> in an external editor.<span id="more-108"></span></p>
<p>You can make Vim automatically activate the <em>mail</em> file type plugin when edit a GMail message by adding the following to ~/.vimrc:</p>
<pre>autocmd BufRead   mail.google.com.* setlocal ft=mail</pre>
<p>Further customization go in ~/.vim/ftplugin/mail.vim:</p>
<pre>setl textwidth=68
call IMAP("sig1","&lt;++&gt;Med venlig hilsen,nMads...","mail")
call IMAP("sig2","&lt;++&gt;Regards,nMads...","mail")</pre>
<p>Wrapping your text makes your mail appear more readable and professional, as the line width does not depend on the width of the receivers window. Remember that GMail automatically wraps text at the 72th column, so be sure that <em>textwidth</em> is lesser than that if you set it. The <em>IMAP</em> lines uses <a href="http://vim-latex.svn.sourceforge.net/viewvc/vim-latex/trunk/vimfiles/plugin/imaps.vim?revision=HEAD">imaps</a> to provide an easy way to handle multiple signatures. The <em>&lt;++&gt;</em> thing indicates where to put the cursor; see the comments in imaps.vim for further info.</p>
<p>Likewise, you can set up Vim to use special syntax highlighting on wiki pages that are edited as plain text. This is great when working with for instance <a href="http://www.vim.org/scripts/script.php?script_id=1113">twiki</a> pages on Trac.</p>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2010/02/being-productive-in-gmail-using-itsalltext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs-like incremental search in Vim</title>
		<link>http://mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/</link>
		<comments>http://mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 12:39:03 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</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() [...]]]></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>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2009/07/emacs-like-incremental-search-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Danish&#8221; Vim-friendy Colemak Layout</title>
		<link>http://mntnoe.com/2008/09/danish-vim-friendy-colemak-layout/</link>
		<comments>http://mntnoe.com/2008/09/danish-vim-friendy-colemak-layout/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:51:14 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</dc:creator>
				<category><![CDATA[Key Bindings]]></category>
		<category><![CDATA[colemak]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.mntnoe.com/?p=48</guid>
		<description><![CDATA[I recently switched to the amazing colemak keyboard layout  &#8211; well, read the FAQ. Also, being Danish (and using Vim), I swapped J and Y (qwerty Y and O). Qwerty Y is the only button I have difficulties reaching, and Danish has many &#8220;hard to reach&#8221; combinations like SKJ. I use AltGr for the Danish [...]]]></description>
			<content:encoded><![CDATA[<p>I recently switched to the amazing <a href="http://colemak.com">colemak</a> keyboard layout  &#8211; well, read the FAQ.</p>
<p>Also, being Danish (and using Vim), I swapped J and Y (qwerty Y and O). Qwerty Y is the only button I have difficulties reaching, and Danish has many &#8220;hard to reach&#8221; combinations like SKJ. I use AltGr for the Danish characters, Æ, Ø, and Å.</p>
<p>Further, by swapping J and Y, the mappings works well in Vim without any remapping (which breaks the consistency). Instead of HJKL I use HONU (qwerty positions), which are fairly easy to reach. It takes quite some time to get used to (especially for Vimmers), but I think it&#8217;s worth it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2008/09/danish-vim-friendy-colemak-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML editing and validation in VIM</title>
		<link>http://mntnoe.com/2008/02/xml-editing-and-validation-in-vim/</link>
		<comments>http://mntnoe.com/2008/02/xml-editing-and-validation-in-vim/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 23:29:01 +0000</pubDate>
		<dc:creator>Mads Navntoft Noe</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 with [...]]]></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://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://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>
]]></content:encoded>
			<wfw:commentRss>http://mntnoe.com/2008/02/xml-editing-and-validation-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

