" 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 autowriteall
"set mouse=a " Enable mouse usage (all modes)
"~/.vimrc
" YouCompleteMe
set runtimepath+=~/.vim/bundle/YouCompleteMe
let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
let g:ycm_complete_in_comments = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_list_select_completion = [‘<c-n>‘, ‘<Down>‘] " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = [‘<c-p>‘, ‘<Up>‘]
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | " 回车即选中当前项
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>| " 跳转到定义处
"let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_server_python_interpreter=‘/usr/bin/python2.7‘
let g:ycm_global_ycm_extra_conf=‘~/.vim/.ycm_extra_conf.py‘
set nocompatible " be iMproved
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"let Vundle manage Vundle
" required!
Bundle ‘indentLine/indentLine‘
Bundle ‘scrooloose/syntastic‘
Bundle ‘gmarik/vundle‘
" My bundles here:
"
" original repos on GitHub
Bundle ‘tpope/vim-fugitive‘
Bundle ‘Lokaltog/vim-easymotion‘
Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}
Bundle ‘tpope/vim-rails.git‘
" vim-scripts repos
Bundle ‘L9‘
Bundle ‘FuzzyFinder‘
" non-GitHub repos
Bundle ‘git://git.wincent.com/command-t.git‘
" Git repos on your local machine (i.e. when working on your own plugin)
Bundle ‘file:///Users/gmarik/path/to/plugin‘
" ...
Bundle ‘Valloric/YouCompleteMe‘
filetype plugin indent on " required!
"javacomplete
setlocal omnifunc=javacomplete#Complete
autocmd Filetype java set omnifunc=javacomplete#Complete
autocmd Filetype java set completefunc=javacomplete#CompleteParamsInf
inoremap <buffer> <C-X><C-U> <C-X><C-U><C-P>
inoremap <buffer> <C-S-Space> <C-X><C-U><C-P>
autocmd Filetype java,javascript,jsp inoremap <buffer> . .<C-X><C-O><C-P>
"增加横线
"autocmd InsertLeave * se nocul " 用浅色高亮当前行
"autocmd InsertEnter * se cul " 用浅色高亮当前行
set cursorline
"highlight CursorLine guibg=lightblue ctermbg=lightgray
"tab 键显示竖线
"set list lcs=tab:\|\
let g:indentLine_char=‘|‘
let g:indentLine_enabled = 1
"let g:indentLine_setColors = 0
" Source a global configuration file if available
filetype plugin indent on
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
set fileformats=unix
"set encoding=prc
set encoding=utf-8
"
"显示行号
set number
"修改vim的tab,使其占4个空格
set tabstop=4
set tags=tags
set tags+=./tags "add current directory‘s generated tags file
set tags+=/usr/tags "add current directory‘s generated tags file
set laststatus=2
set softtabstop=4
set shiftwidth=4
set cindent
"set ff
set autowrite
set ruler
set previewwindow " 标识预览窗口
set showcmd " 命令行显示输入的命令
set showmode " 命令行显示vim当前模式
"--find setting--
set incsearch " 输入字符串就显示匹配点
highlight StatusLine cterm=bold ctermfg=yellow ctermbg=Darkblue
function! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "g")
return curdir
endfunction
set statusline=[%n]\ %f%m%r%h\ \|\ format:\ %{&fileformat}\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=0x%B%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
"进行版权声明的设置
"添加或更新头
map <F4> :call TitleDet()<cr>‘s
function AddTitle()
call append(line("."),"/*=============================================================================")
call append(line(".")+1,"#")
call append(line(".")+2,"# Author: dantezhu - [email protected]")
call append(line(".")+3,"#")
call append(line(".")+4,"# QQ : 327775604")
call append(line(".")+5,"#")
call append(line(".")+6,"# Last modified: ".strftime("%Y-%m-%d %H:%M"))
call append(line(".")+7,"#")
call append(line(".")+8,"# Filename: ".expand("%:t"))
call append(line(".")+9,"#")
call append(line(".")+10,"# Description: ")
call append(line(".")+11,"#")
call append(line(".")+12,"=============================================================================*/")
" echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endfunction
"更新最近修改时间和文件名
function UpdateTitle()
normal m‘
execute ‘/# *Last modified:/[email protected]:.*[email protected]\=strftime(":\t%Y-%m-%d %H:%M")@‘
normal ‘‘
normal mk
execute ‘/# *Filename:/[email protected]:.*[email protected]\=":\t\t".expand("%:t")@‘
execute "noh"
normal ‘k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()
call AddTitle()
return
let n=1
"默认为添加
while n < 10
let line = getline(n)
if line =~ ‘^\#\s*\S*Last\smodified:\S*.*$‘
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction