在安裝vim插件之前,首先安裝Vundle插件,用來管理vim插件,安裝方法查看Vundle在github上的指南。在安裝vundle的時候出現了一個錯誤E117:unknown function vundle#installer#new。造成這個的原因是因為我的.vimrc里面的內容,所以我新建了一個干凈的.vimrc文件后就可以了。
然后去solarized在github上的倉庫,按照教程安裝solarized。
solarized插件安裝好后,由於終端不支持這些配色方案。所以顏色效果和solarized官方網站截圖效果差別很大。
此時需要對終端的配色方案進行調整,調整方法參考了Using Solarized colors with vim, Eclipse and Ubuntu這篇文章。
Gnome Terminal
將下面的代碼保存到.sh文件中,
1 #!/bin/sh 2 # 3 # Shell script that configures gnome-terminal to use solarized theme 4 # colors. Written for Ubuntu 11.10, untested on anything else. 5 # 6 # Solarized theme: http://ethanschoonover.com/solarized 7 # 8 # Adapted from these sources: 9 # https://gist.github.com/1280177 10 # http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/ 11 12 case "$1" in 13 "dark") 14 PALETTE="#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3" 15 BG_COLOR="#00002B2B3636" 16 FG_COLOR="#65657B7B8383" 17 ;; 18 "light") 19 PALETTE="#EEEEE8E8D5D5:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#070736364242:#FDFDF6F6E3E3:#CBCB4B4B1616:#9393A1A1A1A1:#838394949696:#65657B7B8383:#6C6C7171C4C4:#58586E6E7575:#00002B2B3636" 20 BG_COLOR="#FDFDF6F6E3E3" 21 FG_COLOR="#838394949696" 22 ;; 23 *) 24 echo "Usage: solarize [light | dark]" 25 exit 26 ;; 27 esac 28 29 gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false 30 gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false 31 gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "$PALETTE" 32 gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "$BG_COLOR" 33 gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "$FG_COLOR"
然后chmod +x solarized.sh賦予執行權限,命令行下執行./solarized dark,參數可選擇dark 或者 light。
之后再用vim打開文件配色效果就和官網截圖的一樣了。