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


建議直接到 youtube 並切換至 HD 畫質觀看。另外也傳了一份到 vimeo 以及 youku



Ctrll: 清除畫面

Ctrlw: 一次刪除一個字(word)

Ctrlu: 刪除一整行

Ctrlr: 搜尋 history


mode 切換

ia 進入insert mode, i = insert, a = append

在insert mode按下 EscCtrl+[ 回到normal mode

在normal mode按下 vV 進入到visual mode

在visual mode按下 EscCtrl+[ 回到normal mode


h j k l 移動游標

wW 往後跳一個字(word), bB 往前跳一個字(word)。

0 將游標跳回行首, $ 則是跳至行尾。

f 會找到該行的下一個雙引號,fx 會找到該行下一個英文字母"x",以此類推;大寫 F 則是反向。

t 會找到該行的下一個雙引號的前一個位置,tx 會找到該行下一個英文字母"x"的前一個位置,以此類推;大寫 T 則是反向。

{ 往上一個段落移動;} 往下一個段落移動

vit 選取目前游標所在的這個標籤(tag),例如<div>hello</div>則會選取hellovat 則會連帶標籤一起選取,例如<div>hello</div>則會選取<div>hello</div>

vi 選取目前游標所在的這個雙引號內的內容,例如"hello world"則會選取hello worldva 則會連雙引號一起選取。其中雙引號也可以替換成單引號、小括號等符號,功能一樣是選取該符號內的文字。

viw 選取目前游標所在的這個字(word)。

gg 游標跳至整個檔案的第一行;G 游標跳至檔案的最後一行

zt 將目前游標所在位置的內容拉至螢幕的上方;zb 將目前游標所在位置的內容拉至螢幕的下方;zz 將目前游標所在位置的內容拉至螢幕的正中間;

/ 搜尋,搜尋到結果後n可跳至下一個;N可跳至上個。

* 直接搜尋符合游標所在的字(word)


i 進入insert mode,I 游標直接跳至行首,並進入insert mode

a 進入insert mode,A 游標直接跳至行末,並進入insert mode

D 刪除游標所在位置之後的所有內容

C 同上,並直接進入insert mode

x 刪除一個字元

. 重複上一個動作

dd 刪除一整行

3dd 刪除3行

yy 複製游標所在位置的一整行

3yy 從游標處往下複製3行,包含游標所在的那一行

p 貼上內容;4p 從目前游標的所在處貼上內容4次

= 格式整理,gg=G 整份文件格式自動整理

dwdiw 刪除游標所在的那一個字(word)

cwciw 刪除游標所在的一個字(word)並直接進入insert mode

> 增加縮排;< 減少縮排


:w 寫入檔案

:q 離開Vim,若加上!則為強制離開

:tabe 開新tab

gt 切換至下一個tab;gT 切換至上一個tab。(在我的vimrc裡有分別對應到F7跟F8鍵)

:new 新增水平分割視窗;:vnew 新增垂直分割視窗。


Ctrlz 把vim放至背景工作;fg指令則是將vim從背景工作撿回來。



Ruby without Rails

這是在WebDev Party #3上分享的內容,主題是雖然Rails很威很好用,但如果沒有Rails的話,還可以拿Ruby做些什麼其它的事。

投影片: image View on Slideshare | Download PDF


[update] 我也把影片上傳一份到Youtube



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


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



Vim and Plugins




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

[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


Books and Articles


  • 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.


  • 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:


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? :)