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 fedora 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/*,/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 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"
" browsedir设置 set browsedir=buffer
" 自动格式化设置 filetype indent on set autoindent set smartindent
" history文件中需要记录的行数,恢复必须用到。 set history=1024
" 在处理未保存或只读文件的时候,弹出确认 set confirm
" 共享外部剪贴板 set clipboard+=unnamed
" 显示未完成命令 set showcmd " 侦测文件类型 filetype on
" 载入文件类型插件 filetype plugin on
" 为特定文件类型载入相关缩进文件 filetype indent on
" 保存全局变量 set viminfo+=!
" 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,-
" 语法高亮 syntax on
" 设置不兼容模式 set nocp
" 设置鼠标支持 set mouse=a
" 保存窗口大小 set sessionoptions+=resize
" C++头文件识别 au BufEnter /usr/include/c++/* setf cpp au BufEnter /usr/include/g++-3/* setf cpp
" GNU标准 au BufEnter /usr/* call GnuIndent()
" 显示行号 set number
" tab宽度 set tabstop=4 set cindent shiftwidth=4 set autoindent shiftwidth=4
" C/C++注释 set comments=://
" 修正自动C式样注释功能 <2005/07/16> set comments=s1:/*,mb:*,ex0:/
" 标签页设置 if has("gui_running") set showtabline=2 map! tn tabnew nmap <C-c> :tabclose<CR> endif
" 标签页只显示文件名 function ShortTabLabel () let bufnrlist = tabpagebuflist (v:lnum) let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1]) let filename = fnamemodify (label, ':t') return filename endfunction
set guitablabel=%{ShortTabLabel()}
" 使回格键(backspace)正常处理indent, eol, start等 set backspace=eol,start,indent
" 允许backspace和光标键跨越行边界 " set whichwrap+=<,>,h,l
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位) set mouse=a set selection=exclusive set selectmode=mouse,key
" 启动的时候不显示那个援助索马里儿童的提示 set shortmess=atI
" 通过使用: commands命令,告诉我们文件的哪一行被改变过 set report=0
" 不让vim发出讨厌的滴滴声 set noerrorbells
" 在被分割的窗口间显示空白,便于阅读 set fillchars=vert:\ ,stl:\ ,stlnc:\
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 搜索和匹配 " """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 高亮显示匹配的括号 set showmatch
" 匹配括号高亮的时间(单位是十分之一秒) set matchtime=3
" 在搜索的时候忽略大小写 set ignorecase
" 不要高亮被搜索的句子(phrases) " set nohlsearch
" 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索) set incsearch
" 输入:set list命令是应该显示些啥? set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " Tab补全时忽略这些忽略这些 set wildignore=*.o,*.obj,*.bak,*.exe " 光标移动到buffer的顶部和底部时保持3行距离 set scrolloff=3
"搜索出之后高亮关键词 set hlsearch
nmap <silent> <leader><cr> :noh<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " CTags的设定 " """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set tags=tags; " 按照名称排序 let Tlist_Sort_Type = "name"
" 在右侧显示窗口 let Tlist_Use_Right_Window = 1
" 压缩方式 let Tlist_Compart_Format = 1
" 如果只有一个buffer,kill窗口也kill掉buffer let Tlist_Exist_OnlyWindow = 1
" 不要关闭其他文件的tags let Tlist_File_Fold_Auto_Close = 0