11/22/2010

ruby irb環境中使用vim

ruby irb 環境中並不適合編輯程式碼,因此常常浪費時間在編輯上。

gem interactive_editor 簡單整合在irb使用各種編輯器!

安裝過程:

[code] gem install interactive_editor [/code]

vim ~/.irbrc

[code] require 'rubygems' require 'interactive_editor' ... [/code]

自行定義: vim ~/.irbrc

[code] ... class << self def vi(name=nil) InteractiveEditor.edit('/Applications/MacVim.app/Contents/MacOS/Vim', name) end def vim(name=nil) InteractiveEditor.edit('/Applications/MacVim.app/Contents/MacOS/Vim', name) end def gvim(name=nil) InteractiveEditor.edit('/Applications/MacVim.app/Contents/MacOS/Vim -g -f', name) end def mate(name=nil) InteractiveEditor.edit('mate -w', name) end end [/code]

執行irb,直接打vim就可以呼叫MacVim出來編輯之後,vim -> :wq 就會直接執行所編緝程式。

No comments:

Post a Comment