<?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>Dreams of Thought &#187; Linux</title>
	<atom:link href="http://gingerjoos.com/blog/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://gingerjoos.com/blog</link>
	<description>Are dreams thoughts... or are thoughts dreams..</description>
	<lastBuildDate>Sun, 18 Jul 2010 13:05:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>vimdiff &#8211; the cool way to diff for vim users</title>
		<link>http://gingerjoos.com/blog/linux/vimdiff-the-cool-way-to-diff-for-vim-users</link>
		<comments>http://gingerjoos.com/blog/linux/vimdiff-the-cool-way-to-diff-for-vim-users#comments</comments>
		<pubDate>Tue, 20 Oct 2009 16:00:42 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[vimdiff]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=171</guid>
		<description><![CDATA[Some of you using the vim editor may not know about a tool that comes with vim called vimdiff. Vimdiff is an awesome way to diff files if you are a vim nut. It gives you the power of vim + the power of diff. How&#8217;s this different from opening 2 files in vim (with [...]


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/useful-vim-commands' rel='bookmark' title='Permanent Link: Useful vim commands'>Useful vim commands</a></li>
<li><a href='http://gingerjoos.com/blog/technology/twitter-maintenance' rel='bookmark' title='Permanent Link: Twitter maintenance'>Twitter maintenance</a></li>
<li><a href='http://gingerjoos.com/blog/code/firebug-opens-automatically-for-all-pages' rel='bookmark' title='Permanent Link: Firebug opens automatically for all pages'>Firebug opens automatically for all pages</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Some of you using the vim editor may not know about a tool that comes with vim called vimdiff. Vimdiff is an awesome way to diff files if you are a vim nut. It gives you the power of vim + the power of diff.</p>
<p>How&#8217;s this different from opening 2 files in vim (with -O option) you ask ? The difference is that vim will highlight the diff for you.</p>
<p>Fire it up by giving the 2 filenames, say</p>
<p><code>$vimdiff old new</code></p>
<p>This will bring up a screen like this -</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff1.png"><img title="vimdiff" src="http://gingerjoos.com/images/vimdiff1.png" alt="vimdiff" width="512" height="291" /></a><p class="wp-caption-text">vimdiff</p></div>
<p>Now you can move around the 2 parts of the screen with your regular vim commands. For eg. use (Ctrl+w) + right arrow to move to the right half of the screen.</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff2.png"><img title="vimdiff with cursor on right half of screen" src="http://gingerjoos.com/images/vimdiff2.png" alt="vimdiff with cursor on right half of screen" width="512" height="291" /></a><p class="wp-caption-text">vimdiff with cursor on right half of screen</p></div>
<p>You can copy paste as well. Go to the 2nd line in the left half and press the y key twice to copy that line. Use (cntrl + w) + right arrow to move cursor to the 1st line in the right half of the screen. Press p to paste the copied line below the 1st line.</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff3.png"><img title="vimdiff with copy paste" src="http://gingerjoos.com/images/vimdiff3.png" alt="vimdiff with copy paste" width="512" height="219" /></a><p class="wp-caption-text">vimdiff with copy paste</p></div>
<p>You can go to the first line and delete the two words &#8220;a new&#8221; by moving the cursor to &#8220;a&#8221; and hitting d2w key combo.</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff4.png"><img title="vimdiff deletes words" src="http://gingerjoos.com/images/vimdiff4.png" alt="vimdiff deletes words" width="512" height="219" /></a><p class="wp-caption-text">vimdiff deletes words</p></div>
<p>Insert &#8220;an old&#8221; there by going to insert mode(press i key) and then typing the two words. You&#8217;ll see that vimdiff does not highlight anything. This means that there is no difference between the two files.</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff5.png"><img title="two files with no difference in vimdiff" src="http://gingerjoos.com/images/vimdiff5.png" alt="two files with no difference in vimdiff" width="512" height="291" /></a><p class="wp-caption-text">two files with no difference in vimdiff</p></div>
<p>Vimdiff is the same as bringing up vim with the -d option. You could do the same things you did above by using</p>
<p><code>$vim -d old new</code></p>
<p>Bonus :<br />
You can also diff 2 URLs directly with vimdiff<br />
Try<br />
<code>$vimdiff 'http://www.google.co.in/search?q=vimdiff' 'http://www.google.co.in/search?q=vim'</code><br />
You&#8217;ll first see something like this coming on screen<br />
<code><br />
:!curl -o '/tmp/v959288/1' 'http://www.google.co.in/search\?q=vimdiff'<br />
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br />
Dload  Upload   Total   Spent    Left  Speed<br />
"/tmp/v959288/1" 4L, 5289C<br />
:!curl -o '/tmp/v959288/2' 'http://www.google.co.in/search\?q=vim'<br />
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br />
Dload  Upload   Total   Spent    Left  Speed<br />
"/tmp/v959288/2" 4L, 5253C<br />
Press ENTER or type command to continue<br />
</code><br />
Now press the ENTER key to see the diff</p>
<div class="wp-caption aligncenter" style="width: 522px"><a href="http://gingerjoos.com/images/vimdiff6.png"><img title="vimdiff with URLs" src="http://gingerjoos.com/images/vimdiff6.png" alt="vimdiff also works directly with URLs" width="512" height="291" /></a><p class="wp-caption-text">vimdiff also works directly with URLs</p></div>
<p>You can throw in ssh into the mix as well. Try something like this<br />
<code>$vimdiff old <(ssh user@host cat ~/new)</code></p>
<p>If you're a vim/vimdiff ninja and know some more tricks, do post them below <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Happy hacking... </p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/useful-vim-commands' rel='bookmark' title='Permanent Link: Useful vim commands'>Useful vim commands</a></li>
<li><a href='http://gingerjoos.com/blog/technology/twitter-maintenance' rel='bookmark' title='Permanent Link: Twitter maintenance'>Twitter maintenance</a></li>
<li><a href='http://gingerjoos.com/blog/code/firebug-opens-automatically-for-all-pages' rel='bookmark' title='Permanent Link: Firebug opens automatically for all pages'>Firebug opens automatically for all pages</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/vimdiff-the-cool-way-to-diff-for-vim-users/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Copy files preserving the permissions</title>
		<link>http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions</link>
		<comments>http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions#comments</comments>
		<pubDate>Thu, 01 Oct 2009 15:22:17 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[copy files]]></category>
		<category><![CDATA[preserve permissions]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=159</guid>
		<description><![CDATA[You might have come across a situation where your regular usage of the cp command for copying files in your linux box was not enough because while copying you needed to preserve the permissions of the files. Fret not, for help is at hand. Take a look at the man page for cp : -p     [...]


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/useful-vim-commands' rel='bookmark' title='Permanent Link: Useful vim commands'>Useful vim commands</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You might have come across a situation where your regular usage of the <a href="http://en.wikipedia.org/wiki/Cp_%28Unix%29">cp command</a> for copying files in your linux box was not enough because while copying you needed to preserve the permissions of the files. Fret not, for help is at hand. Take a look at the man page for cp :</p>
<p style="padding-left: 30px;"><code>-p     same as --preserve=mode,ownership,timestamps</code></p>
<p style="padding-left: 30px;"><code>--preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, all</code></p>
<p>So that&#8217;s it. just use the -p flag to do the copying. Here&#8217;s an example where I copy a single file while preserving permissions.</p>
<p><code>cp -p oldfile ~/new_dest/</code></p>
<p>To copy a whole directory, I use the -r flag as well.</p>
<p><code>cp -rp some_dir ~/new_dest/</code></p>
<p>You can use the &#8211;preserve flag to keep whatever attributes you need. For the record, there&#8217;s one more related flag</p>
<p style="padding-left: 30px;"><code> --no-preserve=ATTR_LIST               don't preserve the specified attributes</code></p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/useful-vim-commands' rel='bookmark' title='Permanent Link: Useful vim commands'>Useful vim commands</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copying files from one unix box to another with scp</title>
		<link>http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp</link>
		<comments>http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp#comments</comments>
		<pubDate>Fri, 31 Jul 2009 16:53:19 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[rcp]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=133</guid>
		<description><![CDATA[scp (secure copy). scp was meant to be an alternative to unsecure tools like rcp. It has since replaced most such programs. Since scp uses the ssh protocol, the encryption it uses ensures security of your data.


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>ssh is a very powerful and widely used protocol in all the Unices. If you&#8217;ve used the ssh client in your Unix/Linux box, you must have realised how indispensable it is. There is another indispensable tool that uses the ssh protocol &#8211; scp (secure copy). scp was meant to be an alternative to unsecure tools like rcp. It has since replaced most such programs. Since scp uses the ssh protocol, the encryption it uses ensures security of your data.</p>
<p>Using scp is simple. It works almost like the regular cp command. The basic syntax is<br />
<code>scp SOURCE DESTINATION</code><br />
In order to specify the SOURCE or DESTINATION we have a special syntax.<br />
<code>USERNAME@HOST:PATH</code></p>
<p>Let me give you an example :<br />
<code>$scp anirudh@box:/var/www/html/test.html gingerjoos@linux:~/test_dir/</code><br />
Copy /var/www/html/test.html in the machine called &#8220;box&#8221; as user &#8220;anirudh&#8221; to the box called &#8220;linux&#8221; as user &#8220;gingerjoos&#8221; to the path HOMEDIR/test_dir/</p>
<p>That&#8217;s it <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Simple, right?</p>
<p>To copy the file to our localmachine, we could do this<br />
<code>$scp anirudh@box:/var/www/html/test.html ~/workarea/</code></p>
<p>This would copy the file test.html in the machine called &#8220;box&#8221; (as user anirudh) to the localmachine at path HOMEDIR/work_area/</p>
<p>Interchange the source-destination to copy file in your localmachine to the remote machine.</p>
<p>If you want to copy whole directories, use the &#8216;-r&#8217; flag(recursive copy)<br />
<code>$scp -r ~/workarea/ anirudh@box:~/workdir/</code></p>
<p>Since scp is tied to the ssh program, the keys you use to set up passwordless login with ssh works for scp as well.</p>
<p>Got questions? Got something to add to this? Post your comments below <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to join split files</title>
		<link>http://gingerjoos.com/blog/linux/how-to-join-split-files</link>
		<comments>http://gingerjoos.com/blog/linux/how-to-join-split-files#comments</comments>
		<pubDate>Wed, 24 Jun 2009 19:16:19 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=123</guid>
		<description><![CDATA[This is sort of a follow-up to my previous post which talked about <a href="http://gingerjoos.com/blog/linux/hjsplit-and-linux-split">how you can use the split command in Linux to create split files which can be joined with hjsplit on Windows</a>. My theory is that hjsplit does the same thing split does - which is just take the file and split it into the required number of pieces. No special headers or padding or compression or stuff. If that's true, it should be easy as a pie to join the files split with hjsplit


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/hjsplit-and-linux-split' rel='bookmark' title='Permanent Link: hjsplit and linux split'>hjsplit and linux split</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is sort of a follow-up to my previous post which talked about <a href="http://gingerjoos.com/blog/linux/hjsplit-and-linux-split">how you can use the split command in Linux to create split files which can be joined with hjsplit on Windows</a>. My theory is that hjsplit does the same thing split does &#8211; which is just take the file and split it into the required number of pieces. No special headers or padding or compression or stuff. If that&#8217;s true, it should be easy as a pie to join the files split with hjsplit</p>
<p>To join files split with split, what I would do is use cat. Like this :<br />
$cat xaa xab xac xad xae > debian-testing-i386-DVD-1.iso</p>
<p>Here xaa, xab, xac, xad and xae are the split files and debian-testing-i386-DVD-1.iso is the file after the join. I believe this should work fine for split files got from hjsplit too. Since I&#8217;m too lazy to go try it out in my friend&#8217;s Windows machine, I&#8217;ll leave it here at that. Do let me know if anyone&#8217;s tried it <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/hjsplit-and-linux-split' rel='bookmark' title='Permanent Link: hjsplit and linux split'>hjsplit and linux split</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/how-to-join-split-files/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>hjsplit and linux split</title>
		<link>http://gingerjoos.com/blog/linux/hjsplit-and-linux-split</link>
		<comments>http://gingerjoos.com/blog/linux/hjsplit-and-linux-split#comments</comments>
		<pubDate>Tue, 23 Jun 2009 06:28:00 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=107</guid>
		<description><![CDATA[The other day I had to fit in a 4.4 GB file (A Debian testing dvd iso image, if you want to know) on a 4 GB thumb drive. This, of course, is not possible. So I had to split the file into chunks, transfer them twice, take them to my friend&#8217;s windows machine and [...]


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
<li><a href='http://gingerjoos.com/blog/technology/iso-approves-microsofts-ooxml' rel='bookmark' title='Permanent Link: ISO approves Microsoft&#8217;s OOXML'>ISO approves Microsoft&#8217;s OOXML</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The other day I had to fit in a 4.4 GB file (A Debian testing dvd iso image, if you want to know) on a 4 GB thumb drive. This, of course, is not possible. So I had to split the file into chunks, transfer them twice, take them to my friend&#8217;s windows machine and use hjsplit to join the files. How did I split the file so hjsplit could read it, when I didn&#8217;t use the linux version of hjsplit?</p>
<p>It looks like hjsplit splits its files by just cutting them into pieces. This is exactly what is done by the split command. Which is probably why I could use the linux split to split the file into a format hjsplit could join.</p>
<p>You could use a command similar to this one if you want to try it out :</p>
<p>$ split -b900M -d /home/anirudh/downloads/debian/debian-testing-i386-DVD-1.iso debian-testing-i386-DVD-1.iso.</p>
<p>the &#8216;-b&#8217; option is used to specify the size of each chunk &#8211; 900 MB in this case. &#8216;-d&#8217; means the output should be numeric (000,001,002&#8230;). Now we specify the large file and a prefix to attach to the generated filenames (note the dot at the end). This command will generate files :</p>
<p>debian-testing-i386-DVD-1.iso.000</p>
<p>debian-testing-i386-DVD-1.iso.001</p>
<p>debian-testing-i386-DVD-1.iso.002</p>
<p>debian-testing-i386-DVD-1.iso.003</p>
<p>debian-testing-i386-DVD-1.iso.004</p>
<p>Now this should be relatively easy to join with hjsplit. Do some renaming if required.</p>
<p>&nbsp;</a></p>
<p>Edit : </p>
<p> meaculpa has noted that split starts renaming its files with 000 and not 001 as required by hjsplit. Please check <a href='#comment-51'>his comment below</a> for the solution. </p>
<p>As a follow up to this post, I had written another on <a href='http://gingerjoos.com/blog/linux/how-to-join-split-files'>how to join the split files in linux</a>. You can <a href='http://gingerjoos.com/blog/linux/how-to-join-split-files'>check it out as well</a>.</p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
<li><a href='http://gingerjoos.com/blog/technology/iso-approves-microsofts-ooxml' rel='bookmark' title='Permanent Link: ISO approves Microsoft&#8217;s OOXML'>ISO approves Microsoft&#8217;s OOXML</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/hjsplit-and-linux-split/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Useful vim commands</title>
		<link>http://gingerjoos.com/blog/linux/useful-vim-commands</link>
		<comments>http://gingerjoos.com/blog/linux/useful-vim-commands#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:36:32 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[useful vi commands]]></category>
		<category><![CDATA[useful vim commands]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[vim enhanced]]></category>
		<category><![CDATA[vim keyboard shortcuts]]></category>
		<category><![CDATA[vim shortcuts]]></category>

		<guid isPermaLink="false">http://gingerjoos.com/blog/?p=90</guid>
		<description><![CDATA[Now that you've typed some random stuff in, escape to the command mode. Now try pressing ':w' i.e. (shift+;)w. W is for "write". This saves the file and leaves you still in the editor. If you want to get out of the editor, you type in one more command 'q' so it becomes ':wq'. In case you want to get out of it without saving, use ':q!'. The other way to save and quit is to go to the command mode and hit shift+z+z.


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/vimdiff-the-cool-way-to-diff-for-vim-users' rel='bookmark' title='Permanent Link: vimdiff &#8211; the cool way to diff for vim users'>vimdiff &#8211; the cool way to diff for vim users</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://en.wikipedia.org/wiki/Vim_(text_editor)">vim</a> at work for most of my text editing purposes. Vim is a very powerful editor. However, it comes with a somewhat steep learning curve. The best place to learn it would be the vimtutor program. It&#8217;s got a pretty good &#8220;for dummies&#8221; approach which is useful if you haven&#8217;t used an editor even remotely powerful as this one before. If you&#8217;re short of time, the best way to learn it is to just jump in and start using it. Since it&#8217;s been around a long time, it has pretty much most features a developer needs. So if you have a need and don&#8217;t know how to get it done with vim, then use <a href="http://www.google.com">this site</a>.</p>
<p>To start off using vim, let me give you a very quick and dirty first few steps. To open a file, simply use vim &lt;filename&gt;. You most likely have vi pointing to vim. Plus, most of these commands work with other vi&#8217;s anyway. So I&#8217;ll be using vi instead of vim henceforth.</p>
<p>Now that you have a file open, you would like to enter some stuff in? The basic thing you need to know about vi is that it has many modes. From the default mode(command mode) you need to press &#8216;i&#8217; to enter the insert mode. In this mode you can type stuff in and it will show up on the screen. The command mode is where you issue commands to vi (But you can&#8217;t enter text). To go back from the insert mode to command mode press the escape key.</p>
<p>Now that you&#8217;ve typed some random stuff in, escape to the command mode. Now try pressing &#8216;:w&#8217; i.e. (shift+;)w. W is for &#8220;write&#8221;. This saves the file and leaves you still in the editor. If you want to get out of the editor, you type in one more command &#8216;q&#8217; so it becomes &#8216;:wq&#8217;. In case you want to get out of it without saving, use &#8216;:q!&#8217;. The other way to save and quit is to go to the command mode and hit shift+z+z.</p>
<p>With vi, the traditional way to navigate (in command mode) is to use l,k,j,h keys(right,up,down,left). That&#8217;s like the a,w,s,d in gaming. It&#8217;s a timesaver for people who are comfortable with it. Vim allows you to use the arrow keys as well, which is a real convenience.</p>
<p>That covers the bare minimum basics for us.</p>
<p>Once you start using vi you start looking for ways to accomplish tasks using it. There is a whole lot of material out there in the World Wide Web which will help you out. Google is your friend, use it <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I will tell you some of the frequently used options/shortcuts I use with vim.</p>
<p>Going to a specific line : Type in &#8216;:25&#8242; to go to line number 25 (in command mode). You can open a file at a specific line by typing</p>
<p>$ vi +25 FILENAME</p>
<p>This will open the file and take you to line 25. Now that you&#8217;re there, perhaps you would like to delete the next 5 lines? No problem &#8211; just hit d5d. The 5 in the middle says 5 and dd is for deleting lines. You will find this a common pattern with most vi commands. Just hitting dd will remove a single line. Similarly you can do d5w to remove 5 words and dw to remove a single word.</p>
<p>Copy paste is a walk in the  park. Hit y7y to copy 7 lines. Now press p to paste. That&#8217;s it. Cut paste? Hit d7d and then press p to paste after navigating to where you want to paste it.</p>
<p>The other approach to doing all this is to send a command. Hit &#8216;:201,225y&#8217; to copy lines from 201 to 225. Similarly &#8216;:201,225d&#8217; deletes lines from 201 to 225. To jump to a line you can use &#8216;:25&#8242;. This jumps to line number 25.</p>
<p>One useful shortcut when you don&#8217;t want to remember the line numbers is the use of markers. I can mark any 2 lines , say line numbers 201 and 225, and perform an action on them by using the name of the markers. Go to line number 201 and hit &#8216;ma&#8217;. This will mark that line with the marker &#8216;a&#8217;. Do the same with line 225 and mark it with &#8216;b&#8217;. Instead of uisng &#8216;:201,225d&#8217; to delete lines 201 to 225, now you can use the a and b markers to delete the lines thus &#8211; &#8220;:&#8217;a,&#8217;bd&#8221;.</p>
<p>That was just a small snapshot of the commands that I use on vi. You can use a lot other features, like for instance <a href="http://www.oreillynet.com/mac/blog/2006/07/more_vim_save_time_with_macros_1.html">macros</a>, and enhance your editing experience. This should help you get started though. Let me know if this has been useful. Good luck and happy hacking <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/vimdiff-the-cool-way-to-diff-for-vim-users' rel='bookmark' title='Permanent Link: vimdiff &#8211; the cool way to diff for vim users'>vimdiff &#8211; the cool way to diff for vim users</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copy-files-preserving-the-permissions' rel='bookmark' title='Permanent Link: Copy files preserving the permissions'>Copy files preserving the permissions</a></li>
<li><a href='http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux' rel='bookmark' title='Permanent Link: Using Windows partitions from Debian GNU/Linux'>Using Windows partitions from Debian GNU/Linux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/useful-vim-commands/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Windows partitions from Debian GNU/Linux</title>
		<link>http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux</link>
		<comments>http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux#comments</comments>
		<pubDate>Thu, 05 Apr 2007 03:23:09 +0000</pubDate>
		<dc:creator>Anirudh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://dreamsofthought.wordpress.com/2007/04/05/using-windows-partitions-from-debian-gnulinux/</guid>
		<description><![CDATA[My friend Arun recently blogged about Automounting filesystems in Linux from a Fedora perspective. For those of you who want an alternative method (especially Debian users), here goes&#8230; I&#8217;ll explain how I did it &#8211; it&#8217;s much easier to understand from an example. First of all, I used fdisk so I could know which were [...]


Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/hjsplit-and-linux-split' rel='bookmark' title='Permanent Link: hjsplit and linux split'>hjsplit and linux split</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>My friend <a href="http://digitalpbk.blogspot.com/">Arun</a> recently blogged about <a href="http://digitalpbk.blogspot.com/2007/03/auto-mounting-file-systems-in-linux.html">Automounting filesystems in Linux</a> from a <a href="http://en.wikipedia.org/wiki/Fedora_%28Linux_distribution%29">Fedora</a>  perspective. For those of you who want an alternative method (especially <a href="http://en.wikipedia.org/wiki/Debian">Debian</a> users), here goes&#8230;</p>
<p>I&#8217;ll explain how I did it &#8211; it&#8217;s much easier to understand from an example.</p>
<p>First of all, I used <span style="font-style:italic;">fdisk</span> so I could know which were all the partitions in my system and what they were called.</p>
<blockquote><p>debian-indraprastha:/home/anirudh# fdisk -l</p>
<p>Disk /dev/sda: 40.0 GB, 40060403712 bytes<br />
255 heads, 63 sectors/track, 4870 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1        1912    15358108+   c  W95 FAT32 (LBA)<br />
/dev/sda2            1913        3960    16450560    f  W95 Ext&#8217;d (LBA)<br />
/dev/sda3            3961        4870     7309575   83  Linux<br />
/dev/sda5            1913        3187    10241406    b  W95 FAT32<br />
/dev/sda6            3917        3960      353398+  82  Linux swap / Solaris<br />
/dev/sda7            3188        3916     5855661   83  Linux</p></blockquote>
<p>Now take the first entry. That partition is called /dev/sda1 and is the C: drive on Windows. Now I use the mount command to mount the partition. Mounting means that I attach a physical device to a directory, so that the directory itself becomes the device. It&#8217;s a concept that you get used to once you are familiar with all this. To mount the partition, I need a mount point. This is any directory that I create.</p>
<blockquote><p>debian-indraprastha:/home/anirudh# mkdir /disks/c</p></blockquote>
<p>Now I mount /dev/sda1 to /disks/c</p>
<blockquote><p>debian-indraprastha:/home/anirudh# mount /dev/sda1 /disks/c</p></blockquote>
<p>You can check if it has been mounted using the <span style="font-style:italic;">df</span> command.</p>
<blockquote><p>debian-indraprastha:/home/anirudh# df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/sda3             6.9G  4.7G  1.9G  71% /<br />
tmpfs                 253M     0  253M   0% /dev/shm<br />
/dev/sda5             9.8G  7.9G  1.9G  81% /disks/d<br />
/dev/sda7             5.5G  4.6G  702M  87% /disks/s7<br />
tmpfs                  10M  716K  9.4M   7% /dev<br />
/dev/sda1              15G   13G  2.4G  84% /disks/c</p></blockquote>
<p>See the last entry? That shows that /dev/sda1 (the C: drive) has been mounted on /disks/c. Its total size is 15 GB of which 84%(13GB) has been used and 2.4GB is available.</p>
<p>Now there&#8217;s a file called <span style="font-style:italic;">/etc/fstab</span> that comes in very handy. This mounting business is temporary. It gets &#8220;unmounted&#8221; after I shutdown. I would like to automatically mount it each time. I do that by modifying the /etc/fstab file. The /etc/fstab file keeps static information about the filesystems(refer <span style="font-style:italic;">$man fstab</span>). Another file that comes in handy is <span style="font-style:italic;">/etc/mtab</span>. This file keeps info about all the devices that have been mounted. After I mount /dev/sda1, an entry is made in /etc/mtab automatically.</p>
<blockquote><p>/dev/sda1 /disks/c vfat rw 0 0</p></blockquote>
<p>Now I copy this line into my /etc/fstab, with some modifications.</p>
<blockquote><p>/dev/sda1 /disks/c vfat auto,exec,rw 0 0</p></blockquote>
<p>Now each time the system boots, that drive will be mounted automatically.</p>
<p>Now, suppose I don&#8217;t want it to be mounted now? I use <span style="font-style:italic;">unmount</span>.</p>
<blockquote><p>debian-indraprastha:/home/anirudh# umount /dev/sda1</p></blockquote>
<p>To disable the mounting of the paritition automatically, just remove that particular entry from /etc/fstab or uncomment it.</p>
<p>Have fun <img src='http://gingerjoos.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://gingerjoos.com/blog/linux/hjsplit-and-linux-split' rel='bookmark' title='Permanent Link: hjsplit and linux split'>hjsplit and linux split</a></li>
<li><a href='http://gingerjoos.com/blog/linux/copying-files-from-one-unix-box-to-another-with-scp' rel='bookmark' title='Permanent Link: Copying files from one unix box to another with scp'>Copying files from one unix box to another with scp</a></li>
<li><a href='http://gingerjoos.com/blog/linux/how-to-join-split-files' rel='bookmark' title='Permanent Link: How to join split files'>How to join split files</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://gingerjoos.com/blog/linux/using-windows-partitions-from-debian-gnulinux/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.867 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-30 23:36:26 -->
