我正在研究一個紅寶石,我希望能夠隱藏文件中的所有文檔註釋,因爲它們比讀取或編寫代碼更適合使用庫的人。我看到評論的價值,但是當我在編寫代碼時,他們在視覺上讓我感到分心。有沒有辦法在Vim中摺疊所有多行Ruby註釋?
在MacVim中,我可以通過選擇它們並單擊Tools > Folding > Create Fold
手動摺疊代碼行,但有沒有辦法使用某種快捷方式自動隱藏所有註釋?
例如,下面的代碼:
# Returns a 2D array for Rails select helper options.
# Also used internally for Formtastic support
#
# ==== Example
# # Create an Enum with some elements
# class Priority < ClassyEnum::Base
# end
#
# class Priority::Low < Priority; end
# class Priority::ReallyHigh < Priority; end
#
# Priority.select_options # => [["Low", "low"], ["Really High", "really_high"]]
def select_options
map {|e| [e.text, e.to_s] }
end
將顯示爲:
def select_options
map {|e| [e.text, e.to_s] }
end
這與你的問題無關,但你不應該使用菜單:Vim有非常好的默認映射來創建/關閉/打開/刪除和切換摺疊。 ':h fold'會告訴你有關在Vim中摺疊的所有信息。 – romainl 2013-02-10 14:36:29