vim configuration

" 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 "Smart alignment
set autoindent "Automatic alignment
set confirm "When processing unsaved or read-only files, pop-up confirmation
set nu "Display line number
set tabstop=4 "Tab key width
set softtabstop=4
set shiftwidth=4 " Unified indentation is 4
set history=50 "Number of history records

set hlsearch
set incsearch "Search character by character highlight

set gdefault "inline replacement

set nobackup
set cursorline
set ruler "During the editing process, display the status line of the cursor position in the lower right corner
set autoindent
set showcmd "Display currently executed commands in the status line, and unfinished command fragments will also be displayed
set scrolloff=3 " Keep a distance of 3 lines when the cursor moves to the top and bottom of the buffer
set showmatch "Highlight the corresponding brackets
" set paste "Paste does not automatically complete brackets and comments

" Single key <F7> controls syntax on/off. The reason is that sometimes too many colors can hinder reading.
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

"Define a function to escape parentheses
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
" bind the tab key To escape parentheses
inoremap <TAB> <cr>=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 "right display window

""""""""""""""""""""""""""""""""""
"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 " this is required
filetype off " this is required

" You set the runtime path here
set rtp+=~/.vim/bundle/Vundle.vim

" vundle initialization
call vundle#begin()

" This should always be the first
Plugin 'gmarik/Vundle.vim'

" The example is from https://github.com/gmarik/Vundle.vim README
"Plugin 'tpope/vim-fugitive'


" Plugin 'L9' from http://vim-scripts.org/vim/scripts.html
"https://github.com/vim-scripts

"Git plugin not hosted on GitHub
" Plugin 'git: //git.wincent.com/command-t.git'

"git repository on the local machine (ie when writing your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'

" sparkup The vim scripts are in a subdirectory of this repository called vim.
" Pass the path and set the runtime path reasonably.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}

" Avoid name conflict with L9
"Plugin 'user/L9', {'name': 'newL9' }

Plugin 'scrooloose/nerdtree'
" Every plugin should precede this line
"Plugin 'Valloric/YouCompleteMe'
call vundle#end() "

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325020174&siteId=291194637