高見龍

Git/Ruby/Rails/iOS app Developer & Instructor, 喜愛非主流的新玩具 :)

Vim與我的工作環境

我果然是個愛玩又愛現的人,開始來獻曝了,有講的不好的地方(例如聲音不好聽或是長相太嚇人),還請見諒。

如果畫面上的程式碼看不清楚的話,建議可以直接連結到Youtube網站切換到HD畫質,效果會好些。為什麼要連講的人一起錄進來? 因為這次並不是純操作的內容,我覺得有個人在旁邊動呀動的比較不會無聊。

爾後的主題會有:

  • Vim
  • Ruby
  • Rails
  • CoffeeScript
  • Git
  • Flash/ActionScript
  • and others..

每集長度約從10分鐘到30分鐘不等,希望可以每個月至少做個兩集(剛好可以順便幫blog灌一下水)

相關連結

Vim and Plugins

心得

錄Screencast很有趣,會發現自己講話不只卡卡的,還有很多無意義的贅字或發語詞,也很容易NG罵髒話,所以得小段小段的分開錄,錄完再合併。看別人錄都很簡單,自己來才發現要錄製流暢的Screencast難度真的相當高。

以上,不確定大家會不會喜歡這樣的內容或表演方式,或對大家有沒有實質上的幫助,如果大家不嫌棄的話,希望可以繼續玩下去。

新手上路,還請多多指教 :)

[update] 有對岸的朋友說放在youtube會因為某些神奇的原因沒辦法看,所以我也順手上傳了一份到vimeo以及youku

Some Vim Tips and Learning Resources

I’m still pretty new to Vim and keep practicing Vim everyday, and also started to learn some VimScript by myself, I found some nice learning resources and some easy but AWESOME key combinations.

Learning Resources

Screencasts

Books and Articles

Others

  • vimtutor is a great resource, you can type vimtutor in terminal directly to launch it. there’s also some translated version, ex: vimtutor zh would be the tranditional chinese version.
  • last but not the least, the best resource is the built-in HELP manual, just type :h something, and you SHOULD read them through at least one time.

Tips

  • dw : delete a word from current cursor position.
  • diw : delete the whold word which the cursor is parking.
  • dfSpace : delete everything until finding the next Space of the current line.
  • di( : as above, but delete all words within the nearest parenthesis, di[, di, and di also do pretty much the same thing.
  • gv : re-select last visual select.
  • ma to create a marker named a at the current cursor, then by hitting a to jump to the a marker. You can use a to z as the name of the marker.
  • :.![command] will dump the output of the command to your current editing window.
  • %!xxd turn vim to a hex editor, and %!xxd -r will change it back.
  • even you don’t manage your file within any version control system, :earlier 10m can help you to change the current file back to 10 minites ago, and :later 10m will jump back to 10 minites later.
  • :undo 5 will go back by 5 changes, and :undolist will show you undo tree.
  • you can grab web page source code into your editor directly, just like this vim http://www.eddie.com.tw

Some crazy/stupid things

I use Vim almost everyday now, but to be more sophisticated in it, I did some stupid or crazy things.

First, I removed my ESC key from my keyboard temporarily to force myself using Ctrl[, instead of hitting Esc to enter normal mode:

image

Why? actually there’s no good reason, just thought it might keep my fingers on main typing area in mode switching.

and second, I re-map the arrow keys to <NOP> to disable them, both in normal mode and insert mode:

map <UP> <NOP>
map <DOWN> <NOP>
map <LEFT> <NOP>
map <RIGHT> <NOP>
inoremap <UP> <NOP>
inoremap <DOWN> <NOP>
inoremap <LEFT> <NOP>
inoremap <RIGHt> <NOP>

You may think I’m crazy, but I think it’s a faster way to push those things into my muscle memory. I think there’s no shortcut to master Vim, just keep using it everyday.

At last, here is my yet another vimrc configuration. If you have any other tips which are also AWESOME, please let me know :)

Switch to Presentation Mode

I think I’m a show-off person, and usually do presentations to my friends. In this post I mentioned it’s cool to make slide with dark theme or something, but sometimes it won’t be clear enough while putting on projector, and I have to change various settings everytime, that looks not cool and not professional at all.

Thanks for Mike Skalnik, I stole this idea from his Vim config :)

I recorded this video to demonstrate how it looks like. (You might need to change the video to higher resolution if you wanna know what I typed.)

Just press <leader>z, I can toggle between working mode and presentation mode in a second.

It’s actually not a very big deal, you can check the source code to see how to do it. Althought it only works on GUI version Vim (cause I don’t know how to modify font size in terminal version Vim programmatically), but still quite convenient for myself.

I’m really SHOW-OFF, huh? :)

My Vimrc

About 3 months ago, I’ve mentioned I started to use Vim as my primary editor, and now I can only open Vim and Xcode in my daily job(my primary job is coding with Ruby and Rails, and Objective-C is just for fun).

Here is my current vim configuration, feel free to use it, and welcome to give me your suggestion(or criticism). I took some screenshots of my computer and laptop:

MacVim, on iMac with Mac OS X Lion, click to enlarge image

Non-GUI Vim, on iMac with Mac OS X Lion, click to enlarge image

Ubuntu 11.10, click to enlarge image the icons and fonts of the bottom are pretty nice, right? you can check on this, or download from here, and unzip them to ~/.font.

Windows XP, Vim on Windows? I know.. but it’s still working, right? click to enlarge image

Keep polishing

Vim is a pretty awesome and interesting editor, hope can keep polishing it in my daily jobs :)

Ruby Certified Programmer

今天下午我去參加了Ruby的認證考試,運氣不錯,過了。 image

為什麼要去考這個?

其實當初目的很單純,只是想說既然我現在也都有靠 Ruby 在吃飯了,再加上這天剛好我要外出一整天在台北市閒晃,就報名順路去考了。

報名

Ruby Association的網站可以找到相關訊息以及報名方法,台灣幾家比較大的電腦補習班都可以考。

考試時間是 90 分鐘,共有 50 道選擇題(單、複選都有)。英文出題,滿分 100 分,75 分才算及格。英文出題其實不用怕,畢竟不是像托福要考你英文程度的,所以英文題目的敘述不會用太難的字。

喔,忘了說,報名費是 150 塊美金。

心得

我差不多 30 分鐘就寫完了,剩下的時間再重頭全部檢查一次。

可能我運氣好吧,除了幾題陷阱題之外,遇到的題目都不算太難。不過我覺得這考試感覺有點像在考對 API 的記憶力,真的需要花腦筋想的題目不多。有些 API 在實務上並不常用到,所以..我不覺得只要平常有在寫就有辦法通過考試,特別是只有在寫 Rails 的話,不特別準備一下可能過不了的(畢竟是 Ruby 認證,不是 Rails 認證啊)。

準備方向,就.. 常常練習動手寫是基本一定要的(不然我想弄這個證照也沒什麼意義吧),然後在考前再把幾個重要的 Class、Module 的 API “全部"看過一次,應該就差不多了。我運氣不錯,八十幾分低空飛過(這也表示我還不夠熟)。

結論

也許您會好奇,Ruby 證照能幹嘛? 到時候拿去貼滷味攤嗎? 老實說,這對我來說並沒什麼實質用途,我不會因為有多這張認證而加薪、案子變多,或是被大公司挖角。

至於"證照有用/無用"的討論,網路上已經很多了,那也不會是我關心的重點。我去報名認證考試只是單純的想多一張獎狀而已(小時候成績不好,所以家裡牆壁上沒幾張獎狀,所以當年 Adobe 的 Flash Developer 跟 Linux 的 LPI 認證也是這樣來的),順便測試一下自己對 Ruby 的熟悉程度罷了 :)

image
總之,小徽章一枚手入 :)