解決linux下vim亂碼的情況:(修改vimrc的內(nèi)容)
全局的情況下:即所有用戶都能用這個配置
文件地址:/etc/vimrc
在文件中添加:
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set number
如果只修改個人的vim配置情況:
需要把/etc/vimrc復(fù)制到你自己的根目錄下面:復(fù)制為.vimrc(前面有個點,作為隱藏文件)
然后把上面三句話加入到你的文件中,如下圖,保存退出就ok了。

對自己的vim編譯器進行配置:
set nocompatible " 關(guān)閉 vi 兼容模式
syntax on " 自動語法高亮
colorscheme molokai " 設(shè)定配色方案
set number " 顯示行號
set cursorline " 突出顯示當前行
set ruler " 打開狀態(tài)欄標尺
set shiftwidth=4 " 設(shè)定 << 和 >> 命令移動時的寬度為 4
set softtabstop=4 " 使得按退格鍵時可以一次刪掉 4 個空格
set tabstop=4 " 設(shè)定 tab 長度為 4
set nobackup " 覆蓋文件時不備份
set autochdir " 自動切換當前目錄為當前文件所在的目錄
filetype plugin indent on " 開啟插件
set backupcopy=yes " 設(shè)置備份時的行為為覆蓋
set ignorecase smartcase " 搜索時忽略大小寫,但在有一個或以上大寫字母時仍保持對大小寫敏感
set nowrapscan " 禁止在搜索到文件兩端時重新搜索
set incsearch " 輸入搜索內(nèi)容時就顯示搜索結(jié)果
set hlsearch " 搜索時高亮顯示被找到的文本
set noerrorbells " 關(guān)閉錯誤信息響鈴
set novisualbell " 關(guān)閉使用可視響鈴代替呼叫
set t_vb= " 置空錯誤鈴聲的終端代碼
" set showmatch " 插入括號時,短暫地跳轉(zhuǎn)到匹配的對應(yīng)括號
" set matchtime=2 " 短暫跳轉(zhuǎn)到匹配括號的時間
set magic " 設(shè)置魔術(shù)
set hidden " 允許在有未保存的修改時切換緩沖區(qū),此時的修改由 vim 負責(zé)保存
set guioptions-=T " 隱藏工具欄
set guioptions-=m " 隱藏菜單欄
set smartindent " 開啟新行時使用智能自動縮進
set backspace=indent,eol,start
" 不設(shè)定在插入狀態(tài)無法用退格鍵和 Delete 鍵刪除回車符
set cmdheight=1 " 設(shè)定命令行的行數(shù)為 1
set laststatus=2 " 顯示狀態(tài)欄 (默認值為 1, 無法顯示狀態(tài)欄)
set statusline=\ %<%F[%1%M%%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
" 設(shè)置在狀態(tài)行顯示的信息
set foldenable " 開始折疊
set foldmethod=syntax " 設(shè)置語法折疊
set foldcolumn=0 " 設(shè)置折疊區(qū)域的寬度
setlocal foldlevel=1 " 設(shè)置折疊層數(shù)為
" set foldclose=all " 設(shè)置為自動關(guān)閉折疊
" nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" 用空格鍵來開關(guān)折疊
" return OS type, eg: windows, or linux, mac, et.st..
function! MySys()
if has("win16") || has("win32") || has("win64") || has("win95")
return "windows"
elseif has("unix")
return "linux"
endif
endfunction
" 用戶目錄變量VIMFILES =
VIMFILES = $HOME.'/.vim'
endif
" 設(shè)定doc文檔目錄
let helptags=$VIMFILES.'/doc'
" 設(shè)置字體 以及中文支持
if has("win32")
set guifont=Inconsolata:h12:cANSI
endif
" 配置多語言環(huán)境
if has("multi_byte")
" UTF-8 編碼
set encoding=utf-8
set termencoding=utf-8
set formatoptions+=mM
set fencs=utf-8,gbk