Skip to content

Instantly share code, notes, and snippets.

@pwq1989
Last active January 18, 2017 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwq1989/8dbde837971f0ee1bbf9 to your computer and use it in GitHub Desktop.
Save pwq1989/8dbde837971f0ee1bbf9 to your computer and use it in GitHub Desktop.
vimrc
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,cp936
set guifont=Consolas\ 16
" language messages zh_CN.utf-8
" set guifont=Monospace\ 12
set langmenu=zh_CN.UTF-8
set lines=45 columns=100
set number
set autoindent
set smartindent
"set tabstop=4
set tabstop=2
set expandtab
set tags=tags
set autochdir
set hlsearch
set mouse=a
let mapleader=","
set t_Co=256
set whichwrap+=b,s,<,>,[,] "退格和方向键可以换行
set backspace=indent,eol,start "不设定的话在插入状态无法用退格键和 Delete
set ts=2 "tab is 2 space
let g:molokai_original = 1
" set cursorline
set showmatch
" intelligent comments
set comments=sl:/*,mb:\ *,elx:\ */
" in normal mode F4 will save the file
nmap <F4> :w<CR>
nmap <C-S> :w<CR>
" nmap <C-W> :q!<CR>
" in insert mode F4 will exit insert, save, enters insert again
imap <F4> <ESC>:w<CR>i
imap <C-S> <ESC>:w<CR>a
imap <C-W> <ESC>:q!<CR>
nmap <C-Up> :bn<CR>
nmap <C-Down> :bp<CR>
set shiftwidth=4
set foldmethod=manual
syntax enable
colorscheme Molokai
set nocompatible
set nobackup
" taglist
"let Tlist_Show_One_File=1
"let Tlist_Exit_OnlyWindow=1
" let Tlist_File_Fold_Auto_Close=1
" winmanager
" let g:winManagerWindowLayout='FileExplorer|TagList'
"let g:winManagerWindowLayout='NERDTree|TagList'
let g:winManagerWindowLayout='NERDTree'
let g:AutoOpenWinManager = 1
nmap mw :WMToggle<cr>
" minibufExpl
"let g:miniBufExplMapCTabSwitchBufs=1
"let g:miniBufExplMapWindowsNavVim=1
"let g:miniBufExplMapWindowNavArrows=1
" grep
nnoremap <silent> <F3> :Rgrep<CR>
nnoremap <silent> <S-F3> :Rgrep<CR>
let g:cpp_class_scope_highlight = 1
let g:cpp_experimental_template_highlight = 1
" 实现括号自动补全
":inoremap ( ()<ESC>i
":inoremap ) <c-r>=ClosePair(')')<CR>
":inoremap { {}<ESC>i
":inoremap } <c-r>=ClosePair('}')<CR>
":inoremap [ []<ESC>i
":inoremap ] <c-r>=ClosePair(']')<CR>
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'Townk/vim-autoclose'
Plugin 'vim-scripts/matrix.vim--Yang'
"Plugin 'fholgado/minibufexpl.vim'
Plugin 'bling/vim-airline'
Plugin 'Shougo/unite.vim'
Plugin 'vim-scripts/Conque-GDB'
Plugin 'majutsushi/tagbar'
nmap <F8> :TagbarToggle<CR>
let g:ConqueGdb_Leader = '<c-F8>'
" let g:ycm_global_ycm_extra_conf ='~/.vim/.ycm_extra_conf.py'
" let g:ycm_global_ycm_extra_conf ='~/code/gcih-unwind1/.ycm_extra_conf.py'
" let g:ycm_global_ycm_extra_conf ='/home/gin/code/hotspot8/.ycm_extra_conf.py'
let g:ycm_global_ycm_extra_conf ='/home/gin/code/hotspot8/.ycm_extra_conf.py'
let g:ycm_complete_in_strings = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_complete_in_comments = 1
" let g:ycm_error_symbol = '>>'
" 错误提示
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_key_list_select_completion = ['<TAB>','<Enter>', '<Down>']
let g:ycm_enable_diagnostic_highlighting = 0
" let g:ycm_show_diagnostics_ui = 0
let g:ycm_disable_for_files_larger_than_kb = 1000
" syntastic
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <leader>gg :SyntasticCheck<CR> :SyntasticToggleMode<CR>
nnoremap <leader>jj :YcmCompleter GoTo<CR>
nnoremap <leader>jh :YcmCompleter GoToDefinitionElseDeclaration<CR>
" nnoremap <S-Q> :YcmCompleter GoTo<CR>
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
" insert mode shortcut
" Alt + H 光标左移一格
imap <c-h> <Left>
" Alt + J 光标下移一格
imap <c-j> <ESC>ji
" Alt + K 光标上移一格
imap <c-k> <ESC>ki
" Alt + L 光标右移一格
imap <c-l> <Right>
" esc
imap <c-b> <Left><Right><esc><esc><esc>
" Window Switch
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
" 复制粘帖
nmap <leader>bb "+y
nmap <leader>vv "+p
let g:ycm_semantic_triggers = {
\ 'c' : ['->', '.'],
\ 'objc' : ['->', '.'],
\ 'ocaml' : ['.', '#'],
\ 'cpp,objcpp' : ['->', '.', '::'],
\ 'perl' : ['->'],
\ 'php' : ['->', '::'],
\ 'cs,java,javascript,d,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'vim' : ['re![_a-zA-Z]+[_\w]*\.'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ }
" system tags
" ctags -R -f "D:/Vim/systags" --c-kinds=+p --fields=+S D:/mingw-w64/x86_64-4.8.2-posix-seh-rt_v3-rev4/mingw64/include
"set tags+=/home/gin/code/systags
"set tags+=/home/gin/code/ginjson/tags
" set tags+=/home/gin/code/gcih-unwind1/gcih-serialization/vmtags
"set tags+=/home/gin/code/hotspot8/vmtags
nnoremap <C-\> :tnext<CR>
nnoremap <leader>f :Unite -start-insert file<CR>
set autochdir
" DoxyGen
let g:DoxygenToolkit_commentType = "C++"
let g:DoxygenToolkit_briefTag_pre="@brief "
let g:DoxygenToolkit_paramTag_pre="@param "
let g:DoxygenToolkit_returnTag="@returns "
let g:DoxygenToolkit_blockHeader="---------------------------------------------"
let g:DoxygenToolkit_blockFooter="---------------------------------------------"
let g:DoxygenToolkit_authorName="Drunkedcat"
let g:DoxygenToolkit_licenseTag="GPL 2.0"
let g:DoxygenToolkit_authorName="pwq1989"
let s:licenseTag = "Copyright(C)\<enter>"
let s:licenseTag = s:licenseTag . "For free\<enter>"
let s:licenseTag = s:licenseTag . "All right reserved\<enter>"
let g:DoxygenToolkit_licenseTag = s:licenseTag
let g:DoxygenToolkit_briefTag_funcName="yes"
let g:doxygen_enhanced_color=1
" comment
" :inoremap <C-L> <ESC><S-A><SPACE><SPACE><SPACE>///<
" nmap <C-L> <S-A><SPACE><SPACE><SPACE>///<
map <F10> :Dox<CR>
map <F11> :DoxAuthor<CR>
" quickfix
map <leader>ee :cn<CR>
map <leader>er :cp<CR>
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
nmap <leader>ww :bp <BAR> bd #<CR>
fun! SetMkfile()
let filemk = "Makefile"
let pathmk = "./"
let depth = 1
while depth < 4
if filereadable(pathmk . filemk)
return pathmk
endif
let depth += 1
let pathmk = "../" . pathmk
endwhile
return "."
endf
fun! SetMkfileHS()
let filemk = "Makefile"
let pathmk = "./make/linux/"
let depth = 1
while depth < 8
if filereadable(pathmk . filemk)
return pathmk
endif
let depth += 1
let pathmk = "../" . pathmk
endwhile
return "."
endf
command! -nargs=* Make tabnew | let $mkpath = SetMkfile() | make <args> -C $mkpath | cwindow 10
command! -nargs=* MakeHS tabnew | let $mkpath = SetMkfileHS() | make <args> jvmg LP64=1 INCLUDE_TRACE=1 HS_USE_GDBJIT=1 -C $mkpath | cwindow 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment