<?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>chys&#039;s random notes &#187; VIM</title>
	<atom:link href="http://en.chys.info/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.chys.info</link>
	<description>Study more problems; Talk less of isms.</description>
	<lastBuildDate>Tue, 27 Dec 2011 11:56:38 +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>VIM sessions</title>
		<link>http://en.chys.info/2009/03/vim-sessions/</link>
		<comments>http://en.chys.info/2009/03/vim-sessions/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 17:30:12 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://blog.chys.info/?p=394</guid>
		<description><![CDATA[This post basically provides the same info as Reference [1] does. I&#8217;m tired of typing tabe many times every time I continue with a project that has many files. Sure, there is no reason for an omnipotent editor* not to support sessions. Command :mksession (mks) saves the session info to a file (Session.vim by default) [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2008/11/send-ctrl-a-to-sessions-in-screen/' rel='bookmark' title='Send Ctrl-A to sessions in SCREEN'>Send Ctrl-A to sessions in SCREEN</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This post basically provides the same info as Reference [1] does.</p>
<p>I&#8217;m tired of typing <code>tabe</code> many times every time I continue with a project that has many files.</p>
<p>Sure, there is no reason for an omnipotent editor* not to support sessions. Command <code>:mksession</code> (<code>mks</code>) saves the session info to a file (<code>Session.vim</code> by default) that can be <code>source</code>&#8216;d the next time we use VIM. Tell VIM what should or should not be saved by using <code>set sessionoptions</code>.</p>
<p>I&#8217;m too lazy to type all these commands once and again, so I added the following lines to <code>~/.vimrc</code>:</p>
<blockquote><pre>set sessionoptions=sesdir,folds,tabpages
com SL source Session.vim
com SX call SessionSaveAndExit()
function SessionSaveAndExit()
    wa
    mks!
    qa
endfunction</pre>
</blockquote>
<p>Every time I decide to continue with working, I start VIM and type <code>:SL</code>. When I&#8217;m finished, I type <code>:SX</code> and VIM saves all my files and exits.</p>
<p>I dislike to define too many keyboard shortcuts since I frequently press the wrong keys and have no idea what&#8217;s just happened (fortunately we are using VIM instead of the original Vi and we can undo and redo easily), so I use <code>com</code> (abbr. <code>command</code>) instead of <code>nmap</code>.</p>
<p>* I don&#8217;t mean to offend Emacsers &#8211; Emacs is an OS rather than an editor&#8230;</p>
<p>References<br />
[1] <a href="http://cpoucet.wordpress.com/2007/03/06/vim-sessions/">lambda.oasis: Vim Sessions</a><br />
[2] VIM on-line help, of course (e.g. type <code>:help sessionoptions</code> in VIM)</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2008/11/send-ctrl-a-to-sessions-in-screen/' rel='bookmark' title='Send Ctrl-A to sessions in SCREEN'>Send Ctrl-A to sessions in SCREEN</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2009/03/vim-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIM modelines</title>
		<link>http://en.chys.info/2009/02/vim-modelines/</link>
		<comments>http://en.chys.info/2009/02/vim-modelines/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 23:23:04 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://blog.chys.info/?p=255</guid>
		<description><![CDATA[I was wondering why all Emacs modeline samples I found online worked so well, but no VIM ones worked at all. In fact, VIM by default disables modelines because it is a potential security hole. (This is too bad. They can enable only safe instructions by default.) Add set modeline to ~/.vimrc to enable it. [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2009/03/vim-sessions/' rel='bookmark' title='VIM sessions'>VIM sessions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was wondering why all Emacs modeline samples I found online worked so well, but no VIM ones worked at all. <del datetime="2009-03-11T02:52:10+00:00">In fact, VIM by default disables modelines because it is a potential security hole. (This is too bad. They can enable only safe instructions by default.)</del> Add <code>set modeline</code> to <code>~/.vimrc</code> to enable it.</p>
<p>A modeline is some instructions to the editor put in the comments, usually in the beginning of a text file. The most common use is probably to set the syntax highlighting rule, tab width and indent.</p>
<p>Modeline example:<br />
<code>/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</code><br />
<code>/* vim:set ft=cpp ts=2 sw=2 sts=2 cindent: */</code></p>
<p>The first line is for Emacs and the second for VIM. <del datetime="2009-03-10T05:45:57+00:00">Note that an Emacs modeline must appear in the beginning of a file, while VIM modelines can be put anywhere.</del></p>
<p>Basicly, these two lines force the file type to be C++ (especially useful for <code>.h</code> files, which are by default treated as C sources), set the width of a tab to be 2 characters and enable auto indention. (My knowledge about Emacs is very limited, so probably this is not accurate.)</p>
<p>Some resources:<br />
1. <a href="http://www.delorie.com/gnu/docs/emacs/emacs_486.html">GNU Emacs modeline documentation</a><br />
2. <a href="http://vimdoc.sourceforge.net/htmldoc/options.html#modeline">VIM modeline documentation</a></p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2009/03/vim-sessions/' rel='bookmark' title='VIM sessions'>VIM sessions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2009/02/vim-modelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

