Linux下vim常用配置

来源:互联网 发布:淘宝商城平台 编辑:程序博客网 时间:2024/06/16 09:49

vim的配置文件默认安装在/etc/vimrc目录下,vi类似
这些是vim的常用配置

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"   set fileencodings=ucs-bom,utf-8,latin1endifset 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 fileset viminfo='20,\"50    " read/write a .viminfo file, don't store more            " than 50 lines of registersset history=50      " keep 50 lines of command line historyset ruler       " show the cursor position all the time" Only do this part when compiled with support for autocommandsif 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 ENDendifif 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 csverbendif" 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 hlsearchendiffiletype plugin onif &term=="xterm"     set t_Co=8     set t_Sb=[4%dm     set t_Sf=[3%dmendif" Don't wake up system with blinking cursor:" http://www.linuxpowertop.org/known.phplet &guicursor = &guicursor . ",a:blinkon0""与windows共享剪贴板set clipboard+=unnamed"显示行号, 或set numberset nu"历史命令保存行数 set history=100 "高亮光标所在行set cursorline"允许使用鼠标点击定位set mouse=a"状态栏显示当前执行的命令set showcmd"标尺功能,显示当前光标所在行列号set ruler"设置命令行高度为3set cmdheight=3"粘贴时保持格式set paste"高亮显示匹配的括号set showmatch"在搜索的时候忽略大小写set ignorecase"高亮被搜索的句子set hlsearch"在搜索时,输入的词句的逐字符高亮(类似firefox的搜索)set incsearch"继承前一行的缩进方式,特别适用于多行注释set autoindent"为C程序提供自动缩进set smartindent"使用C样式的缩进set cindent"制表符为4set tabstop=4"统一缩进为4set softtabstop=4set shiftwidth=4"允许使用退格键,或set backspace=2set backspace=eol,start,indentset whichwrap+=<,>,h,l"取消换行set nowrap"启动的时候不显示那个援助索马里儿童的提示set shortmess=atI"在被分割的窗口间显示空白,便于阅读set fillchars=vert:\ ,stl:\ ,stlnc:\"光标移动到buffer的顶部和底部时保持3行距离, 或set so=3set scrolloff=3"设定默认解码set fenc=utf-8set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936"设定字体set guifont=Courier_New:h11:cANSIset guifontwide=新宋体:h11:cGB2312"设定编码set enc=utf-8set fileencodings=ucs-bom,utf-8,chineseset langmenu=zh_CN.UTF-8language message zh_CN.UTF-8source $VIMRUNTIME/delmenu.vimsource $VIMRUNTIME/menu.vim"自动补全filetype plugin indent onset completeopt=longest,menu"自动补全命令时候使用菜单式匹配列表set wildmenuautocmd FileType ruby,eruby set omnifunc=rubycomplete#Completeautocmd FileType python set omnifunc=pythoncomplete#Completeautocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJSautocmd FileType html set omnifunc=htmlcomplete#CompleteTagsautocmd FileType css set omnifunc=csscomplete#CompleteCSSautocmd FileType xml set omnifunc=xmlcomplete#CompleteTagsautocmd FileType java set omnifunc=javacomplete#Complet