linux下.vimrc文件配置
set nocompatible //不要使用vi的鍵盤模式,而是vim自己的
set syntax=on //語法高亮
set noeb //去掉輸入錯誤的提示聲音
set confirm //在處理未保存或只讀文件的時候,彈出確認
set autoindent set cindent //自動縮進
set tabstop=4Tab //鍵的寬度
set softtabstop=4 set shiftwidth=4 // 統一縮進為4
set noexpandtab //不要用空格代替制表符
set smarttab //在行和段開始處使用制表符
set number //顯示行號
set history=1000 //歷史記錄數
set nobackup set noswapfile //禁止生成臨時文件
set ignorecase //搜索忽略大小寫
set hlsearch set incsearch //搜索逐字符高亮
set gdefault //行內替換
set enc=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 //編碼設置
set langmenu=zh_CN.UTF-8 set helplang=cn //語言設置
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(“%d/%m/%y\ -\ %H:%M”)} set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] //我的狀態行顯示的內容(包括文件類型和解碼)
set laststatus=2 //總是顯示狀態行
set ruler //在編輯過程中,在右下角顯示光標位置的狀態行
set cmdheight=2 //命令行(在狀態行下)的高度,默認為1,這里是2
filetype on //偵測文件類型
filetype plugin on //載入文件類型插件
filetype indent on //為特定文件類型載入相關縮進文件
et viminfo+=! //保存全局變量
set iskeyword+=_,$,@,%,#,- //帶有如下符號的單詞不要被換行分割
set linespace=0 //字符間插入的像素行數目
set wildmenu //增強模式中的命令行自動完成操作
set backspace=2 // 使回格鍵(backspace)正常處理indent, eol, start等
set whichwrap+=,h,l //允許backspace和光標鍵跨越行邊界
//可以在buffer的任何地方使用鼠標(類似office中在工作區雙擊鼠標定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key
//通過使用: commands命令,告訴我們文件的哪一行被改變過
set report=0
//啟動的時候不顯示那個援助索馬里兒童的提示
set shortmess=atI
//在被分割的窗口間顯示空白,便於閱讀
set fillchars=vert:\ ,stl:\ ,stlnc:\
//高亮顯示匹配的括號
set showmatch
//匹配括號高亮的時間(單位是十分之一秒)
set matchtime=5//光標移動到buffer的頂部和底部時保持3行距離
set scrolloff=3
//為C程序提供自動縮進
set smartindent
//只在下列文件類型被偵測到的時候顯示行號,普通文本文件不顯示
if has(“autocmd”)
autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number
autocmd FileType xml,html vmap ‘o’>o–>
autocmd FileType java,c,cpp,cs vmap ’
autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100
autocmd Filetype html,xml,xsl source
$VIMRUNTIME/plugin/closetag.vim
autocmd BufReadPost *
\ if line(“’”“) > 0 && line(“’”“) <= line(“$”) |
\ exe “normal g`”” |
\ endif
endif ” has(“autocmd”)
//F5編譯和運行C程序,F6編譯和運行C++程序
//請注意,下述代碼在windows下使用會報錯
//需要去掉./這兩個字符
//C的編譯和運行
map :call CompileRunGcc()
func! CompileRunGcc()
exec “w”
exec “!gcc % -o %
exec “! ./%
endfunc
//C++的編譯和運行
map :call CompileRunGpp()
func! CompileRunGpp()
exec “w”
exec “!g++ % -o %
exec “! ./%
endfunc
//能夠漂亮地顯示.NFO文件
set encoding=utf-8
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
au BufReadPre *.nfo call SetFileEncodings(‘cp437’)|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()
//高亮顯示普通txt文件(需要txt.vim腳本)
au BufRead,BufNewFile * setfiletype txt
//用空格鍵來開關折疊
set foldenable
set foldmethod=manual
nnoremap @=((foldclosed(line(‘.’)) < 0) ? ‘zc’ : ‘zo’)
//” minibufexpl插件的一般設置
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1