在用戶主目錄下建立 .vimrc文件,用戶
也可以在/etc/vimrc(/etc/vim/vimrc不同版本,可能不一樣),全局
添加下面內容:
"語法高亮
syntax on
"顯示行號
set nu
"修改默認注釋顏色
hi Comment ctermfg=DarkCyan
"允許退格鍵刪除
set backspace=2
"啟用鼠標
set mouse=a
set selection=exclusive
set selectmode=mouse,key
"偵測文件類型
filetype on
"載入文件類型插件
filetype plugin on
"為特定文件類型載入相關縮進文件
filetype indent on
"設置編碼自動識別, 中文引號顯示
set fileencodings=utf-8,gbk
set encoding=euc-cn
set ambiwidth=double
"設置高亮搜索
set hlsearch
"在搜索時,輸入的詞句的逐字符高亮
set incsearch
"按C語言格式縮進
set cindent
"設置Tab長度為4格
set tabstop=4
"設置自動縮進長度為4格
set shiftwidth=4
"繼承前一行的縮進方式,特別適用於多行注釋
set autoindent
"顯示括號匹配
set showmatch
"括號匹配顯示時間為1(單位是十分之一秒)
set matchtime=1
"增強模式中的命令行自動完成操作
set wildmenu
"不要生成swap文件,當buffer被丟棄的時候隱藏它
setlocal noswapfile
set bufhidden=hide