Tag Archives: vim

the Power of Regex

Today I solved a problem during my work in help of vim and regex. Take a note here, in case I forget it someday.

There are two files(excel A and word B) for me to figure out whether the names in word B are also existed in excel A. Excel A and word B look like this:

Excel A:

From Drop Box

Word B:

From Drop Box

First of all, if I want to compare the two files, I should copy the names in word B to excel A and use the function vlookup, this suppose to be simple, so I don’t want to talk about this part. The main problem here is how to transform the names in word B to some other format, each name in a row actually. So, the objective is set, let’s begin to solve it.

  1. Copy the entire word B to gvim C, because vim is truly a word editor and it is where the regex can take full advantage of.
  2. There are two space between each name, we should turn them to one. It’s time for regex to roll out.

    :%s/ss/ /gc

    “s” means match a white space character, exactly a space and a tab.

  3. And some names contain two character, but they also have a space between them, we should eliminate these space.

    :%s/s(S)s/ 1/gc

    “S” means match anything that isn’t a space and a tab and “(…)” means making matched subtexts available in the replacement part of a substitute command, such as “1”.

  4. Replace every space to a carriage return, this one seems a piece of cake.


    “r” means a carriage return.

  5. Copy the entire contexts to excel A, and transfer the job to function vlookup. The contexts should look like this:
  6. From Drop Box

If the excel A and word B are some big files, we’ll save great amount of time using regex. In my case, they really are. And I think I did my job nice and easy.

How to install Firefox 4 (Stable) In Ubuntu [10.04 and 10.10]

Source: How To Install Firefox 4 (Stable) In Ubuntu [10.04 and 10.10]

Now Firefox 4 (stable) has finally released, I cannot wait to have a try. Though I use Chrome quite a lot nowadays, Firefox was once my favorite. Somehow it’s a little bit slow, but it can highly customize, that win my heart, besides, I’m quite indulge in”Pentadactyl“, an add-on to emulate vim in the browser. Of course, Chrome has the similar extension, “Vimium“, but I suppose  “Pentadactyl” is better.

If your OS is other than Ubuntu, you can probably find Firefox installer in this page, download it, click and install, simple and easy. And if you happened to use Ubuntu like me, then follow these steps:

  1. If you are using the development version of Firefox, remove it with the command,
    sudo apt-get remove firefox-4.0
    If you are not using the development version, skip this step.
  2. Now add the Firefox stable PPA.
    sudo add-apt-repository ppa:mozillateam/firefox-stable
  3. Now update the software list
    sudo apt-get update
  4. Finally install Firefox 4 with the command.
    sudo apt-get install firefox
    After installation, you will find Firefox under Applications > Internet > Firefox Web Browser.

Some of the add-ons are not compatible with Firefox 4, such as “Autoproxy”, I don’t know how to fix it now, but I’m sure with the help Almighty Google, you can find your way.

O.k., let’s surf.












  1. %s/a/b/x: vim中的替换命令,用b的内容替换a,x是参数,设定范围等信息。
  2. n: vim中的换行符。
  3. /: 转义/,因为在这个替换命令中“/”有特殊含义,是命令的分隔符,而我们真正需要的,作为普通字符处理的“/”如何表示呢?就要借助转义符“”,“/”即表示把“/”当普通字符处理。
  4. /g: 表示全文搜索,没有这个参数,默认是搜索当前行。
  5. 这只是个简单应用,其实有更简洁更高级的写法。这里就不罗列了。
  6. 如果你一点也看不懂也没有关系,因为我是写给自己看的,讲得很乱。有兴趣的请自行学习vim,绝对会让你有白活半辈子的感觉。


先痛骂电信劫持了我网站的域名!登自己网站,上来竟给我来电信的广告,HOLY FUCK!一时激动忘了截图了,下次一定记得。



我是在这里找到的解决方法,同时也看到了不少其他linux快捷键的介绍(没有全看完,不过乍一看就发现第二条写错了。<Alt><Fn>是无法切换终端的,应该是<Ctrl><Alt><Fn> (n=1..6) 才对),现在的习惯是看到好的资源文章就想办法找找英文的,英文资源比中文资源要好的多,技术文章就更不用说了。。。出处可能是在这里:Linux Shortcuts and Commands. 果然很强大啊,排版都看着舒服,只是不免有些沮丧,这才刚刚是Linux Newbie Administrator Guide,啥时候才能入门啊?