簡單的 .vimrc 配置

若是是在 Linux 中使用 Vim,那麼這裏就有一個現成的配置:/usr/share/vim/vim74/vimrc_example.vim,其中 74 是版本號,你的可能會有所不一樣。
把它拷到本身的主目錄下,重命名爲.vimrcvim

  1. $ cp /usr/share/vim/vim74/vimrc_example.vim ~/.vimrc

這樣,語法高亮代碼縮進這些喜聞樂見的特性,馬上就自動生效了。
另外,在文件末尾再添加一些我的的習慣配置:code

1.  set nobackup
2.  set noundofile
3.    
    
4.  set expandtab
5.  setlocal shiftwidth=4
6.  setlocal softtabstop=4
7.  inoremap ( ()《Left》
8.  inoremap { {}《Left》
9.  inoremap \[ \[\]《Left》
10.  inoremap " ""《Left》
11.  inoremap ' ''《Left》
12.    
    
13.  let loaded\_matchparen=1
14.  set matchpairs+=<:>

補充上自動補齊括號匹配tab 鍵擴展。這樣,寫代碼的基本需求就知足了,最起碼比直接用記事本,要舒服太多了。
另外,別忘了將鼠標禁用,否則右鍵粘貼會無論用。
將文件中有關 mouse 的這段注掉,改爲下面這樣:ci

1.  " In many terminal emulators the mouse works just fine, thus enable it.
2.  " if has('mouse')
3.  " set mouse=a
4.  " endif

就能夠了。 rem

PS: 附上博主經常使用的.vimrc配置terminal

1.  set nobackup
2.  set noundofile
3.  set cindent
4.  set nu
5.    
    
6.  inoremap ( ()《Left》
7.  inoremap \[ \[\]《Left》
8.  inoremap { {}《Left》《CR》《ESC》O
9.  inoremap ' ''《Left》
10.  inoremap " ""《Left》
相關文章
相關標籤/搜索