highlight GTK+ APIs in vim
找到一個方便的套件,順便抱怨一下在 debian 遇到的怪異相依性問題
這兩天在 apt 上亂找軟體,發現一個叫 vim-syntax-gtk,看起來應該是 vim 的 syntax file,不過要安裝時發現牽扯了一堆莫名其妙的相依性
~# apt-get install vim-syntax-gtk
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
python2.5 python2.5-minimal
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
libruby1.8 ruby ruby1.8 vim-addon-manager
Suggested packages:
rdoc1.8 ri1.8 ruby1.8-examples
The following NEW packages will be installed:
libruby1.8 ruby ruby1.8 vim-addon-manager vim-syntax-gtk
0 upgraded, 5 newly installed, 0 to remove and 48 not upgraded.
Need to get 1980kB of archives.
After this operation, 6984kB of additional disk space will be used.
Do you want to continue [Y/n]?
竟然想把我的 python 換成 ruby…所以我直接下載原始檔手動裝上。
使用上很簡單,用 vim 開啟檔案後,設定 syntax 即可
:set syn=c.gtk.gdk.glib.cairo
要省事一點可以用 autocmd 設定,但因為不是每個 c file 都需要開這麼多 highlight,再加上我也不是那麼常寫 gtk+ 程式,我還是選擇手動設定吧。另外透過 view,設定過一次就會被記住,這邊一樣用 autocmd 來做,設定方式是建立一個 ~/.vim/view 目錄,並在 ~/.vimrc 加上這兩行:
au BufWinEnter *.c,*.cpp,*.php,*.py,*.pl,*.f,*.hs,*.el silent loadview
au BufWinLeave *.c,*.cpp,*.php,*.py,*.pl,*.f,*.hs,*.el mkview
file pattern 的部份請自行調整成適合的檔案類型,需要更進階的設定可以參考 autocmd 的說明 (:h au)