2014年7月13日 星期日

[Go] 在 Ubuntu 14.04 中設定 Go Syntax Highlight for Vim

為了在 Ubuntu 用 vim 編輯 *.go 檔案時有 syntax highlight 的效果

要額外安裝 vim-syntax-go 套件,並做些許設定

詳細步驟如下:

1、安裝 vim & vim-syntax-go

2、找到 go.vim 檔案 (在我的電腦裡是在 /usr/share/vim/addons/syntax 目錄中),並放到 ~/.vim/syntax 目錄中

3、編輯 ~/.vim/ftdetect/go.vim 檔案,並輸入以下內容
au BufRead,BufNewFile *.go set filetype=go
4、編輯 ~/.vimrc 檔案,輸入以下內容
" size of a hard tabstop
set tabstop=4
" size of an "indent"
set shiftwidth=4
" a combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop
set softtabstop=4
set rtp+=/usr/share/vim/addons
filetype plugin indent on
syntax on
view raw .vimrc hosted with ❤ by GitHub

最後登出再登入就完工囉! 

沒有留言:

張貼留言