简单的 .vimrc 配置

29次阅读

共计 611 个字符,预计需要花费 2 分钟才能阅读完成。

如果是在 Linux 中使用 Vim,那么这里就有一个现成的配置:/usr/share/vim/vim74/vimrc_example.vim,其中 74 是版本号,你的可能会有所不同。把它拷到自己的主目录下,重命名为 .vimrc:
$ cp /usr/share/vim/vim74/vimrc_example.vim ~/.vimrc

这样,语法高亮、代码缩进 这些喜闻乐见的特性,立刻就自动生效了。另外,在文件末尾再添加一些个人的习惯配置:
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 的这段注掉,改成下面这样:
” In many terminal emulators the mouse works just fine, thus enable it.
” if has(‘mouse’)
” set mouse=a
” endif

就可以了。

正文完
 0