2010
01.21

以往我使用 vim 的時機大概都是編輯設定檔,或是做些小修改,但最近因為某些原因,開始強迫自己用 vim 做正經事(儘管我不是很想),也因此在網路上找到不少人的 .vimrc。 vim 可供設定的參數非常多,也可以加裝非常多 powerful 的 plug-in ,甚至連 auto-complete 都可以辦到!不過我目前只有使用基本的功能而已,所以設定參數只有下面寥寥幾行。

備註: .vimrc 是 vim (VIM – Vi IMproved) 編輯器的設定檔,一般放置於使用者的家目錄中。

" 檔案編碼
set encoding=utf-8
set fileencodings=utf-8,cp950

" 編輯喜好設定
syntax on        " 語法上色顯示
set nocompatible " VIM 不使用和 VI 相容的模式
" set ai           " 自動縮排
set shiftwidth=2 " 設定縮排寬度 = 4
set tabstop=4    " tab 的字元數
set softtabstop=4
" set expandtab   " 用 space 代替 tab

set ruler        " 顯示右下角設定值
set backspace=2  " 在 insert 也可用 backspace
set ic           " 設定搜尋忽略大小寫
set ru           " 第幾行第幾個字
set hlsearch     " 設定高亮度顯示搜尋結果
set incsearch    " 在關鍵字還沒完全輸入完畢前就顯示結果
set smartindent  " 設定 smartindent
set confirm      " 操作過程有衝突時,以明確的文字來詢問
set history=100  " 保留 100 個使用過的指令
set cursorline   " 顯示目前的游標位置

set laststatus=2
set statusline=%4*%<\%m%<[%f\%r%h%w]\ [%{&ff},%{&fileencoding},%Y]%=\[Position=%l,%v,%p%%]

colorscheme torte

我的 colorscheme 是用 torte ,一般的 linux 裝好 vim 應該都會有這個配色,實際看起來會像:

一些相關的連結:
c9s – vim – 很多進階的用法,作者對 vim 非常熟稔,也寫了很多很棒的文章。
給程式設計師的Vim入門圖解說明 – 這陣子推薦非常多人看。
vi / vim 圖解鍵盤指令 – 我最早找到的圖解說明

No Comment.

Add Your Comment
:alien: :angel: :angry: :blink: :blush: :cheerful: :cool: :cwy: :devil: :dizzy: :ermm: :face: :getlost: :biggrin: :happy: :heart: :kissing: :lol: :ninja: :pinch: :pouty: :sad: :shocked: :sick: :sideways: :silly: :sleeping: :smile: :tongue: :unsure: :w00t: :wassat: :whistle: :wink: :wub:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>