若是是在 Linux 中使用 Vim,那麼這裏就有一個現成的配置:/usr/share/vim/vim74/vimrc_example.vim,其中 74 是版本號,你的可能會有所不一樣。
把它拷到本身的主目錄下,重命名爲 .vimrc:vim
$ cp /usr/share/vim/vim74/vimrc_example.vim ~/.vimrc
這樣,語法高亮、代碼縮進 這些喜聞樂見的特性,馬上就自動生效了。
另外,在文件末尾再添加一些我的的習慣配置:code
set nobackup set noundofile set expandtab setlocal shiftwidth=4 setlocal softtabstop=4 inoremap ( ()<LEFT> inoremap { {}<LEFT> inoremap [ []<LEFT> inoremap " ""<LEFT> inoremap ' ''<LEFT> let loaded_matchparen=1 set matchpairs+=<:>
補充上 自動補齊、括號匹配、tab 鍵擴展。這樣,寫代碼的基本需求就知足了,最起碼比直接用記事本,要舒服太多了。
另外,別忘了將鼠標禁用,否則右鍵粘貼會無論用。
將文件中有關 mouse 的這段注掉,改爲下面這樣:rem
" In many terminal emulators the mouse works just fine, thus enable it. " if has('mouse') " set mouse=a " endif
就能夠了。terminal