vim配置

" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below. If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set shell=/bin/bash

set smartindent "智能对齐
set autoindent "自动对齐
set confirm "在处理未保存或只读文件的时候,弹出确认
set nu "显示行号
set tabstop=4 "Tab键的宽度
set softtabstop=4
set shiftwidth=4 "统一缩进为4
set history=50 "历史记录数

set hlsearch
set incsearch "搜索逐字符高亮

扫描二维码关注公众号,回复: 85304 查看本文章

set gdefault "行内替换

set nobackup
set cursorline
set ruler "在编辑过程中,在右下角显示光标位置的状态行
set autoindent
set showcmd "在状态行显示目前所执行的命令,未完成的指令片段亦会显示出来
set scrolloff=3 "光标移动到buffer的顶部和底部时保持3行距离
set showmatch "高亮显示对应的括号
"set paste "粘贴不自动补全括号及注释

" 单键<F7>控制syntax on/off。原因是有时候颜色太多会妨碍阅读。
map <F7> :if exists("syntax_on") <BAR>
\ syntax off <BAR><CR>
\ else <BAR>
\syntax enable <BAR>
\ endif


"""""""""""""""""""""""""""""""""""
" 括号自动生成、跳出
"""""""""""""""""""""""""""""""""""
"括号自动生成
"inoremap ' ''<ESC>i
"inoremap " ""<ESC>i
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {<CR>}<ESC>O

" 定义跳出括号函数,用于跳出括号
func SkipPair()
if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'" || getline('.')[col('.') - 1] == '}'
return "\<ESC>la"
else
return "\t"
endif
endfunc
" 将tab键绑定为跳出括号
inoremap <TAB> <c-r>=SkipPair()<CR>

""""""""""""""""""""""""""""""""""
"plugin-->cscope
"""""""""""""""""""""""""""""""""""
"cscope设置
if has("cscope")
set csprg=/usr/bin/cscope
"set cscopequickfix=s-,c-,d-,i-,t-,e-
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
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> "search for this c symbol
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> "search for this string
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>

""""""""""""""""""""""""""""""""""
"plugin-->taglist
"""""""""""""""""""""""""""""""""""
let Tlist_Auto_Open=1 "auto open Tlist
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则直接退出vim
let Tlist_Show_One_File = 1 "only show current file's Tlist
let Tlist_Compact_Format=1 "Hide help menu
let Tlist_Ctags_Cmd = '/usr/bin/ctags' "设置ctags程序的位置
let Tlist_Use_Right_Window = 1 "右侧显示窗口

""""""""""""""""""""""""""""""""""
"plugin-->NERDTree
"""""""""""""""""""""""""""""""""""
map <F10> :NERDTreeToggle<CR>
autocmd vimenter * NERDTree "自动打开NERDTree
" 当vim中没有其他文件,值剩下nerdtree的时候,自动关闭窗口
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif


set nocompatible " 这是必需的
filetype off " 这是必需的

" 你在此设置运行时路径
set rtp+=~/.vim/bundle/Vundle.vim

" vundle初始化
call vundle#begin()

" 这应该始终是第一个
Plugin 'gmarik/Vundle.vim'

" 该例子来自https://github.com/gmarik/Vundle.vim README
"Plugin 'tpope/vim-fugitive'

" 来自http://vim-scripts.org/vim/scripts.html的插件
"Plugin 'L9'
"https://github.com/vim-scripts

"未托管在GitHub上的Git插件
"Plugin 'git://git.wincent.com/command-t.git'

"本地机器上的git软件库(即编写自己的插件时)
"Plugin 'file:///home/gmarik/path/to/plugin'

" sparkup vim脚本在名为vim的该软件库子目录下。
" 传递路径,合理设置运行时路径。
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}

" 与L9避免名称冲突
"Plugin 'user/L9', {'name': 'newL9'}

Plugin 'scrooloose/nerdtree'
" 每个插件都应该在这一行之前
"Plugin 'Valloric/YouCompleteMe'
call vundle#end() " required
filetype plugin indent on " required

猜你喜欢

转载自www.cnblogs.com/zhchy89/p/8967211.html