<?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>Morgajel.net &#187; Vim</title>
	<atom:link href="http://morgajel.net/category/open-source/vim/feed" rel="self" type="application/rss+xml" />
	<link>http://morgajel.net</link>
	<description>Stemming the flow of evincible Ignorance. We must try to understand for the sake of understanding.</description>
	<lastBuildDate>Sun, 25 Jul 2010 20:48:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Intro to Vim Tip #6 (Multiple viewports)</title>
		<link>http://morgajel.net/2008/07/21/261</link>
		<comments>http://morgajel.net/2008/07/21/261#comments</comments>
		<pubDate>Mon, 21 Jul 2008 21:02:08 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/?p=261</guid>
		<description><![CDATA[One feature of vim I don&#8217;t use enough is the ability to split the screen and view multiple files at once. I use this feature all the time when I use vimdiff, but not really any other time. I thought I&#8217;d take a moment to lay out some uses of it (thank Linux.com for the [...]]]></description>
			<content:encoded><![CDATA[<p>One feature of vim I don&#8217;t use enough is the ability to split the screen and view multiple files at once. I use this feature all the time when I use vimdiff, but not really any other time. I thought I&#8217;d take a moment to lay out some uses of it (thank <a href='http://www.linux.com/articles/54157'>Linux.com</a> for the reference):</p>
<p>From Command Mode:</p>
<ul>
<li>:sp splits the screen horizontally</li>
<li>:vsp splits the screen vertically</li>
<li>Ctrl-w Ctrl-w moves between viewports</li>
<li>Ctrl-w [right arrow] moves active viewport 1 to the right</li>
<li>Ctrl-w [left arrow] moves active viewport 1 to the left</li>
<li>Ctrl-w 3[left arrow] moves active viewport 3 to the left</li>
<li>Ctrl-w q will close the active window.</li>
</ul>
<p>and remember that you can open a file with <img src='http://morgajel.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' />  filename in the newly created viewport</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2008/07/21/261/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Intro to Vim Tip #5 (Recording)</title>
		<link>http://morgajel.net/2007/10/07/220</link>
		<comments>http://morgajel.net/2007/10/07/220#comments</comments>
		<pubDate>Sun, 07 Oct 2007 06:47:37 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2007/10/07/220/</guid>
		<description><![CDATA[Search and replace is a great feature in most text editors, but what happens when you want to do more? Vim has a solution- recording macros. Suppose you have the following output from some ancient program that needs to be tweaked: X1222 22323 2A22 3303 0000 3334esss test 123 X2222 22353 2A22 3303 0001 3334esss [...]]]></description>
			<content:encoded><![CDATA[<p>Search and replace is a great feature in most text editors, but what happens when you want to do more? Vim has a solution- recording macros. Suppose you have the following output from some ancient program that needs to be tweaked:</p>
<p><code><br />
X1222 22323 2A22 3303 0000 3334esss test 123<br />
X2222 22353 2A22 3303 0001 3334esss tacd 456<br />
X3222 22383 2A22 3303 0010 3334esss fals 789<br />
X4222 22393 2A22 3303 0011 3334esss true 012<br />
</code></p>
<p>It is doesn&#8217;t really matter what it is, this example is somewhat contrived. Suppose you needed to make the following changes for each line that starts with X:<br />
* change the ID from X_222 to Y_223<br />
* reverse the 4th and 5th fields<br />
* copy the second character from the beginning and insert it before the last character of the line</p>
<p>If it were only 4 lines, you could handle this yourself, but it would be very tedious. Suppose rather than 4 lines, you had 400- it&#8217;d be much easier to automate it. The best way to take care of it would be with a macro:<br />
<code><br />
[esc]qa<br />
/^X[enter] i[delete]Y[right][right][right][delete]3<br />
[esc]wwwdww[left]p<br />
0[right]d[ctrl+v]y$[shift+p]<br />
q<br />
</code><br />
That right there is a MESS, but gets the job done- it&#8217;s not something you want to repeat for fear of a typo. Notice that the first characters you typed were qa: &#8216;q&#8217; starts recording, and &#8216;a&#8217; is the slot we&#8217;re using to store the macro. From here we record how *we* would make the changes, making sure to keep our keystrokes to a minimum. When we&#8217;re done, we stop the macro by pressing &#8216;q&#8217; again.</p>
<p>To run our macro on the next line, press &#8216;@a&#8217; to run the newly created &#8216;a&#8217; macro- it should find the next line that starts with an X (notice the /^X in our first command) and run those commands to massage our text.</p>
<p>Remember how we were talking about 400 lines like this? Even at 2 characters each, that&#8217;s 800 characters to type which is still annoying. Here&#8217;s where the magic comes in- you can record macros of macros:<br />
<code><br />
qb<br />
@a@a@a@a@a@a@a@a@a@a<br />
q<br />
</code><br />
Now each time you run @b, you&#8217;ll run the a macro 10 times. A more efficient way to handle this would be to use<br />
<code><br />
@a<br />
398@@<br />
</code><br />
the first one was done manually to record the macro, the second to play the macro, and the third to say run it 398 more times. </p>
<p>And there you go- a quick tour of recording macros. I&#8217;m sure there&#8217;s much more than what I&#8217;ve shown, but that&#8217;s enough to keep you busy.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2007/10/07/220/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spell checking only *.txt files in Vim</title>
		<link>http://morgajel.net/2007/08/06/215</link>
		<comments>http://morgajel.net/2007/08/06/215#comments</comments>
		<pubDate>Mon, 06 Aug 2007 20:37:50 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2007/08/06/215/</guid>
		<description><![CDATA[So vim 7 has native spell checking- which is great if you remember to turn it on. Enabling it in your .vimrc is fine if all you view is written text files, but annoying when it&#8217;s running while working on code. That&#8217;s why I created this little snippet of sunshine: add this to ~/.vimrc: au [...]]]></description>
			<content:encoded><![CDATA[<p>So vim 7 has native spell checking- which is great if you remember to turn it on. Enabling it in your .vimrc is fine if all you view is written text files, but annoying when it&#8217;s running while working on code.</p>
<p>That&#8217;s why I created this little snippet of sunshine:</p>
<p>add this to ~/.vimrc:</p>
<pre>
au BufNewFile,BufRead *.txt call ConfigureTxtFile()

func! ConfigureTxtFile()
    setlocal spell spelllang=en_us
    set wrapmargin=80
    set textwidth=80
endfunction
</pre>
<p>I also use it to set my text width and wrap margins. You can have it match other types of files as well and create new functions- I plan on using this to set .py files to use space-replaced tabs. As I go forward I might have it do something a bit more fancy.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2007/08/06/215/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Intro to Vim Tip #4 (Pasting)</title>
		<link>http://morgajel.net/2006/07/14/145</link>
		<comments>http://morgajel.net/2006/07/14/145#comments</comments>
		<pubDate>Fri, 14 Jul 2006 12:56:42 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2006/07/14/145/</guid>
		<description><![CDATA[If you need to paste into vim from somewhere else, and your code has tabs or spaces in it, you&#8217;ll notice that vim may add extra tabs. see, vim doesn&#8217;t see it as a paste event, it sees it as &#8220;you typing really fast&#8221;- and one thing vim does will is auto-indent. The problem is [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to paste into vim from somewhere else, and your code has tabs or spaces in it, you&#8217;ll notice that vim may add extra tabs.  see, vim doesn&#8217;t see it as a paste event, it sees it as &#8220;you typing really fast&#8221;- and one thing vim does will is auto-indent.  The problem is when you paste, you don&#8217;t want auto-indentation because your code is already indented.</p>
<p>to temporarily turn off auto-indenting, try this from insert mode:</p>
<pre>[esc]:set paste[enter]</pre>
<p>go back to insert mode and you should be able to paste without the extra tabs.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2006/07/14/145/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Intro to Vim Tip #3 (Visual Mode)</title>
		<link>http://morgajel.net/2006/07/10/141</link>
		<comments>http://morgajel.net/2006/07/10/141#comments</comments>
		<pubDate>Mon, 10 Jul 2006 14:38:19 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2006/07/10/141/</guid>
		<description><![CDATA[Another well used mode is Visual Mode, which turns your cursor into a hilighter. open a textfile with several lines of text ad move the cursor to the middle switch from command mode to visual mode: v You&#8217;ll notice as you move the cursor around, you highlight different sections from the point you started to [...]]]></description>
			<content:encoded><![CDATA[<p>Another well used mode is Visual Mode, which turns your cursor into a hilighter.<br />
open a textfile with several lines of text ad move the cursor to the middle</p>
<p>switch from command mode to visual mode:</p>
<pre>v</pre>
<p>You&#8217;ll notice as you move the cursor around, you highlight different sections from the point you started to the point you left. you can press [esc] to return to command mode.</p>
<p>hilight a few lines of text from command mode:</p>
<pre>[shift]v[upkey]</pre>
<p>my adding the modifier [shift] when pressing V, you switch to &#8216;visual line mode&#8217;. This allows you to copy paragraphs easily.</p>
<p>hilight a block of text from command mode:</p>
<pre>[ctrl]v[upkey][upkey][rightkey]</pre>
<p>Now what good is visual mode? we&#8221; for deleting or replacing, of course!  This is great when you have the following block of text:</p>
<pre>
           [option min="1"  max="10"   ][/option]
            [option min="11" max="19"   multiplier="10000" ]cp[/option]
            [option min="20" max="38"   multiplier="1000"  ]sp[/option]
            [option min="39" max="95"   multiplier="100"   ]gp[/option]
            [option min="96" max="100"  multiplier="10"    ]pp[/option]
</pre>
<p>and you&#8217;ve decided you no longer need min and max.<br />
- move the cursor in command mode over the &#8216;m&#8217; in &#8216;min&#8217; on the first line<br />
- press [ctrl]v[downkey][downkey][downkey][downkey]<br />
- press the right arrowkey until the closing quote on &#8220;100&#8243; is covered<br />
- press &#8216;d&#8217;<br />
all your text will be gone. But suppose you didn&#8217;t want the text to be gone, you wanted to replace it with something else?<br />
- press &#8216;u&#8217; and the text will reappear<br />
- re-highlight it and press &#8216;c&#8217;  (text should disapepar)<br />
- type your replacement string (use=&#8221;false&#8221;) and press [esc]<br />
within a moment or two,  use=&#8221;false&#8221; should jump up across all five lines</p>
<p>Visual modes are also useful for narrowing the scope of a search and replace, but I&#8217;ll get to that when I cover search and replacing.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2006/07/10/141/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Vim Tip #2 (deleting)</title>
		<link>http://morgajel.net/2006/07/10/140</link>
		<comments>http://morgajel.net/2006/07/10/140#comments</comments>
		<pubDate>Mon, 10 Jul 2006 14:14:24 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2006/07/10/140/</guid>
		<description><![CDATA[Deleting in vim can be done several ways- in insert mode, the delete key and backspace key perform as you&#8217;d expect them to, but what if you want more? delete the character to the left of the cursor: [esc]d[left arrow] delete the character to the right of the cursor: [esc]d[right arrow] deleting the current line [...]]]></description>
			<content:encoded><![CDATA[<p>Deleting in vim can be done several ways- in insert mode, the delete key and backspace key perform as you&#8217;d expect them to, but what if you want more?</p>
<p>delete the character to the left of the cursor:</p>
<pre>[esc]d[left arrow]</pre>
<p>delete the character to the right of the cursor:</p>
<pre>[esc]d[right arrow]</pre>
<p>deleting the current line from insert mode:</p>
<pre>[esc]dd</pre>
<p>deleting the current line and the one below from insert mode:</p>
<pre>[esc]d[downkey]</pre>
<p>deleting the current line and the one above from insert mode:</p>
<pre>[esc]d[upkey]</pre>
<p>deleting current character and 4 to the right:</p>
<pre>d5[rightkey]</pre>
<p>deleting current line and 2 below:</p>
<pre>d2[downkey]</pre>
<p>You&#8217;ll notice from those last two examples that deleting characters to the left and right include the current character in the count, but deleting lines above and below do not.  Weird.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2006/07/10/140/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Vim Tip #1</title>
		<link>http://morgajel.net/2006/07/10/139</link>
		<comments>http://morgajel.net/2006/07/10/139#comments</comments>
		<pubDate>Mon, 10 Jul 2006 13:40:17 +0000</pubDate>
		<dc:creator>morgajel</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://morgajel.net/2006/07/10/139/</guid>
		<description><![CDATA[Vim is a great tool, but using is can be a pita in the beginning- hence, we go through the basics. There are several command modes, but we&#8217;ll only discuss a few at first: Command Mode and Insert Mode. Command mode is used to perform actions like saving, searching, etc. Insert mode is used to [...]]]></description>
			<content:encoded><![CDATA[<p>Vim is a great tool, but using is can be a pita in the beginning- hence, we go through the basics. There are several command modes, but we&#8217;ll only discuss a few at first: Command Mode and Insert Mode.</p>
<p>Command mode is used to perform actions like saving, searching, etc. Insert mode is used to insert and delete text. You&#8217;ll be switching between them a lot.</p>
<p>Open a file from the cli:</p>
<pre>  $ vim foo.php</pre>
<p>change to insert mode from Command mode:</p>
<pre>  press 'i'</pre>
<p>change to command mode from insert mode:</p>
<pre>  press [esc]</pre>
<p>save from insert mode:</p>
<pre>  press [esc]:w[enter]</pre>
<p>save and quit from insert mode:</p>
<pre>  press [esc]:wq[enter]</pre>
<p>quit and do NOT save from insert mode:</p>
<pre>  press [esc]:q![enter]</pre>
<p>An there you have it.</p>
]]></content:encoded>
			<wfw:commentRss>http://morgajel.net/2006/07/10/139/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
