vim的配置文件默認安裝在/etc/vimrc目錄下,vi類似
這些是vim的常用配置
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
filetype plugin on
if &term=="xterm"
set t_Co=8
set t_Sb=[4%dm
set t_Sf=[3%dm
endif
" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"
"與windows共享剪貼板
set clipboard+=unnamed
"顯示行號, 或set number
set nu
"歷史命令保存行數
set history=100
"高亮光標所在行
set cursorline
"允許使用鼠標點擊定位
set mouse=a
"狀態欄顯示當前執行的命令
set showcmd
"標尺功能,顯示當前光標所在行列號
set ruler
"設置命令行高度爲3
set cmdheight=3
"粘貼時保持格式
set paste
"高亮顯示匹配的括號
set showmatch
"在搜索的時候忽略大小寫
set ignorecase
"高亮被搜索的句子
set hlsearch
"在搜索時,輸入的詞句的逐字符高亮(類似firefox的搜索)
set incsearch
"繼承前一行的縮進方式,特別適用於多行註釋
set autoindent
"爲C程序提供自動縮進
set smartindent
"使用C樣式的縮進
set cindent
"製表符爲4
set tabstop=4
"統一縮進爲4
set softtabstop=4
set shiftwidth=4
"允許使用退格鍵,或set backspace=2
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
"取消換行
set nowrap
"啓動的時候不顯示那個援助索馬里兒童的提示
set shortmess=atI
"在被分割的窗口間顯示空白,便於閱讀
set fillchars=vert:\ ,stl:\ ,stlnc:\
"光標移動到buffer的頂部和底部時保持3行距離, 或set so=3
set scrolloff=3
"設定默認解碼
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
"設定字體
set guifont=Courier_New:h11:cANSI
set guifontwide=新宋體:h11:cGB2312
"設定編碼
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"自動補全
filetype plugin indent on
set completeopt=longest,menu
"自動補全命令時候使用菜單式匹配列表
set wildmenu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet