<?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>Chunhao&#039;s Blog &#187; vim</title>
	<atom:link href="http://chunhao.net/blog/category/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://chunhao.net/blog</link>
	<description>Life happens. Love helps.</description>
	<lastBuildDate>Fri, 28 May 2021 12:36:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Why Python</title>
		<link>http://chunhao.net/blog/why-python/</link>
		<comments>http://chunhao.net/blog/why-python/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 05:32:19 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=151</guid>
		<description><![CDATA[Why Python? If it&#8217;s not 10 times better than other languages (except for the running speed), I won&#8217;t bother it. Let me give you an example to show Python&#8217;s awesomeness and attractiveness. Refer to this page for the problem. We are asked to compute the first ten digits of the sum of one-hundred 50-digit numbers: [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Why Python? If it&#8217;s not 10 times better than other languages (except for the running speed), I won&#8217;t bother it.</p>
<p>Let me give you an example to show Python&#8217;s awesomeness and attractiveness.</p>
<p>Refer to <a href="http://projecteuler.net/index.php?section=problems&amp;id=13">this page</a> for the problem. We are asked to compute the first ten digits of the sum of one-hundred 50-digit numbers:</p>
<blockquote><p>37107287533902102798797998220837590246510135740250<br />
46376937677490009712648124896970078050417018260538<br />
74324986199524741059474233309513058123726617309629<br />
&#8230;</p></blockquote>
<p>Suppose you are using C/C++, you probably need to use array to handle each digit of these long numbers, since these languages don&#8217;t support such long integers. If you are using Python, things will be very easy.</p>
<p>Just copy/paste these numbers into a file. Edit it with Vim. Use Vim command:</p>
<blockquote><p>:%s/$/,/g</p></blockquote>
<p>to add a comma to the end of each line. Remove the last comma. Then insert &#8220;array = [&#8221; to the beginning of the first line and add a &#8220;]&#8221; to the end of the last line.</p>
<p>Add the following to another line:</p>
<blockquote><p>print sum(array)</p></blockquote>
<p>Save this file and run it with Python and here we are done.</p>
<p>Here you can see that Python can handle arbitrary large number, as long as you memory can hold it. This is just a tip of the iceberg of Python&#8217;s advantage. Use it and you will get more and more.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/why-python/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Are Your Fingers Long Enough to Use Vim?</title>
		<link>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/</link>
		<comments>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 12:14:27 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=122</guid>
		<description><![CDATA[Note: I wrote this post just for fun. Please don’t take it seriously. Thank you! Which editor are you using, Vim or Emacs? And why? Next time, when you are arguing with other people about which editor is better and trying to persuade others to use your favorite editor, just forget it. If you believe [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><span style="color: #ff0000;">Note: I wrote this post just for fun. Please don’t take it seriously.</span> <span style="color: #ff0000;"> Thank you!</span> <img src="http://chunhao.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>Which editor are you using, Vim or Emacs? And why?</p>
<p>Next time, when you are arguing with other people about which editor is better and trying to persuade others to use your favorite editor, just forget it. If you believe everything is in destiny, it is not an exception for the editor you choose. The choice is written on your fingers.</p>
<p>Several days ago, I learnt from <a href="http://mike.struct.cn">Mike</a> that the choice between using Vim or Emacs depends on your fingers. As he figured out, people have longer fingers prefer to use Vim, while people have shorter fingers prefer to use Emacs. It is amazing, but reasonable.</p>
<p>Using Vim, the most frequent key you hits might be the &#8220;Esc&#8221;. Vim has three modes: insert mode, command mode and visual mode. Command mode is the bridge of other two modes, and most of navigating and searching is done in command mode. So, when you are using Vim, you must: press &#8220;a&#8221; or &#8220;i&#8221; to start insert mode and input something, then press the &#8220;Esc&#8221; to enter the command mode and do navigation, then enter the insert mode again and then press the &#8220;Esc&#8221; to the command mode. Maybe some times you want to hit &#8220;v&#8221; to enter the visual mode to select something, and after that you must hit the &#8220;Esc&#8221; again back to the command mode. At most time, you are hitting the &#8220;Esc&#8221;. That&#8217;s why they call Vim &#8220;hit Esc to death&#8221;. Of course, you also need Ctrl and Shift in vim, but not so often. For example, when you select contents by line or by block, you will press &#8220;Shift+v&#8221; or &#8220;Ctrl+v&#8221;. When you want to jump to the end of a line, you will press &#8220;$&#8221;(Shift+4). But these cases are much rearer than hitting the &#8220;Esc&#8221;. So, when your fingers are long enough, you will find it very comfortable and easy to hit the &#8220;Esc&#8221;. Maybe that&#8217;s why you like to use Vim.</p>
<p>I have touched Emacs for little times. In Emacs, almost everything except for inputing text are done by &#8220;Ctrl+something&#8221;, &#8220;Shift+something&#8221;, &#8220;Alt+something&#8221;, or even &#8220;Ctrl+Alt/Shift+something&#8221;. That means at most time, one of your finger must hit &#8220;Ctrl&#8221;, &#8220;Shift&#8221; or &#8220;Alt&#8221;. That&#8217;s why they call Emacs &#8220;hit Ctrl to death&#8221;. Some Emacs fans even want to use pedals to help them hit hot keys. I have to twist my fingers to hit those keys. For some complicated combination of keys, I even don&#8217;t know how to hit them comfortably and elegantly. So I gave up Emacs soon to save my hands and fingers. Maybe people who have shorter fingers would fall in love with Emacs because they could hit these hot keys easily without twisting their fingers very much.</p>
<p>Although I prefer Vim, I don&#8217;t mean to comment Emacs and Emacs users. Emacs is also powerful, and even more powerful than Vim (at least in my mind). I admire Emacs users very much because they can learn so many hot keys by heart and use them gently and easily.</p>
<p>If you are still confusing about choosing Vim or Emacs, just check your finger. If your fingers are longer than most of your friends, then just choose Vim without hesitate and you will like the life of hitting the &#8220;Esc&#8221;. If your fingers are shorter than average and you find it&#8217;s uncomfortable to hit the &#8220;Esc&#8221; frequently, then you should definitely choose Emacs.</p>
<p>If you are still arguing with other people about Vim and Emacs, forget it, unless you want to cut some one&#8217;s finger to force them to use Emacs or lengthen some one&#8217;s finger to force them to use Vim.</p>
<p>If you are jeered by Emacs users for you are using such a disharmonious editor that has multiple confusing modes, you could respond them, &#8220;at least I have beautiful long fingers&#8221;. If you are sneered by Vim users for you are using such a complicated editor that requires a pedal to handle the hot keys, you could respond them, &#8220;at least my memory is better than you, since I could remember thousands of hot keys&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How to connect vim with gdb — using clewn</title>
		<link>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/</link>
		<comments>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 05:22:40 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/?p=6</guid>
		<description><![CDATA[First, I will show you the screen shot The screen of vim is divide into two sub windows, the top one can display the code and the bottom one shows the variable you want to watch. Well, this can be changed by you, you can split the window any way you like. You can use [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a title="screenshot3.png" href="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot3.png"><img src="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot3.thumbnail.png" alt="screenshot3.png" /></a></p>
<p><span class="postbody">First, I will show you the screen shot</span> The screen of vim is divide into two sub windows, the top one can display the code and the bottom one shows the variable you want to watch.  Well, this can be changed by you, you can split the window any way you like.  You can use C-B to make a break, and press R to run your program, and press S to step, and C-J to add the variable you want to watch. <span class="postbody"> You can download clewn here:</span></p>
<blockquote><p><span class="postbody"><a href="http://clewn.sourceforge.net/" target="_blank">http://clewn.sourceforge.net/</a></span></p></blockquote>
<p>How to install:  <span class="postbody">first of all, you should have your gvim installed,</span></p>
<blockquote>
<p align="left">sudo apt-get install vim-gnome</p>
</blockquote>
<p><span class="postbody">as well as gdb</span> And then download the source file of clewn; note here, not vimgdb.  And extract the file, then use your terminal to enter the clewn folder</p>
<blockquote><p>./configure make sudo make install</p></blockquote>
<p>Note here, may be some one will be suffered from the dependency problem during their installing. If your machine tell you that you need readline, then install libreadline5-dev</p>
<blockquote><p>sudo apt-get install libreadline5-dev</p></blockquote>
<p><span class="postbody"> And then, copy some files to ~/.vim you can refer my folder:</span></p>
<blockquote><p>cp /usr/local/share/vim/vimfiles/clewn.vim ~/.vim/plugin/</p>
<p>cp /usr/local/share/vim/vimfiles/doc/clewn.txt ~/.vim/doc/</p>
<p>cp /usr/local/share/vim/vimfiles/macros/clewn_mappings.vim ~/.vim/macros/</p>
<p>cp /usr/local/share/vim/vimfiles/syntax/gdbvar.vim ~/.vim/syntax/</p></blockquote>
<p>Then, every thing is done. You can write a small program to test.</p>
<pre lang="c">#include 

int main(int argc, char *argv[]) {
  int i;
  int s;
  s = 0;
  for (i = 0; i &lt; 10; ++i) {
    s = s + 1;
  }
}</pre>
<p><span class="postbody"> Save it as test.c , for example. And then,</span></p>
<blockquote><p>gcc -g -o test test.c</p></blockquote>
<p>If everything is right during compiling, then</p>
<blockquote><p>clewn -va test.c</p></blockquote>
<p><span class="postbody">Then, gdb is opened on your terminal, and your gvim is opened at the same time</span> Cool down now; input the following on your terminal(gdb):</p>
<blockquote><p>file test</p></blockquote>
<p>Now, you can debug your program on gvim.  <span class="postbody">For example, you can click the line you want to set break point. And then press CTRL+B, then, break point is set.</span> SHIFT+r（that is capital R）It will run and stop at your break point SHIFT+s（that is capital S）It will step And watch your variable, input following on gvim</p>
<blockquote><p>:split</p></blockquote>
<p><span class="postbody">Then the window will be split, and then click the variable you want to watch, and press C+J, then you can see the variable appears in another window.</span> <span class="postbody">To do this, you also can input the following on your terminal(gdb)</span></p>
<blockquote><p>createvar yourvar</p></blockquote>
<p>&#8220;youvar&#8221; represents the variable you want to watch.  Following is the default shortcuts</p>
<p>List of default key mappings:</p>
<blockquote>
<pre><span class="Special">        CTRL-Z</span>  send an interrupt to GDB and the program it is running
        B       info breakpoints
        L       info locals
        A       info args
        S       step
        I       stepi
        <span class="Special">CTRL-N</span>  next: next source line, skipping all function calls
        X       nexti
        F       finish
        R       run
        Q       quit
        C       continue
        W       where
        <span class="Special">CTRL-U</span>  up: go up one frame
        <span class="Special">CTRL-D</span>  down: go down one frame

<span class="PreProc">cursor position:</span><span class="Ignore"> ~</span>
        <span class="Special">CTRL-B</span>  set a breakpoint on the line where the cursor is located
        <span class="Special">CTRL-E</span>  clear all breakpoints on the line where the cursor is located

<span class="PreProc">mouse pointer position:</span><span class="Ignore"> ~</span>
        <span class="Special">CTRL-P</span>  print the value of the variable defined by the mouse pointer
                position
        <span class="Special">CTRL-X</span>  print the value that is referenced by the address whose
                value is that of the variable defined by the mouse pointer
                position
        <span class="Special">CTRL-K</span>  set a breakpoint at assembly address shown by mouse position
        <span class="Special">CTRL-H</span>  clear a breakpoint at assembly address shown by mouse position
        <span class="Special">CTRL-J</span>  add the selected variable at mouse position to the watched
                variables window</pre>
</blockquote>
<p>This is referred the official document, which is available here</p>
<blockquote><p><a href="http://clewn.sourceforge.net/" target="_blank"></a><a href="http://clewn.sourceforge.net/doc.html" target="_blank">http://clewn.sourceforge.net/doc.html</a></p></blockquote>
<p>Hope this will help you somewhat. If you have some new or better idea, please contact me.  chunhao86@gmail.com  Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
