From 64436bf70832028052dd278760761230d7d0bc77 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Sun, 6 Sep 2015 05:08:14 +0200 Subject: switched to vundle, cleaned and commented the vimrc --- vimrc | 767 +++++++++++++++--------------------------------------------------- 1 file changed, 166 insertions(+), 601 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index ea96df4..b14ac67 100644 --- a/vimrc +++ b/vimrc @@ -1,622 +1,187 @@ -call pathogen#infect() -" Pathogen +"================================================================================ +" Vundle: plugin manager... +set nocompatible| " do not try to be vi, be vim +filetype off| " Vundle needs this +set rtp+=~/.vim/plugins/Vundle.vim +call vundle#begin('~/.vim/plugins/') + +" Plugin dependant configurations... +Plugin 'VundleVim/Vundle.vim' +Plugin 'cscope_plus.vim' " run cscope -R -b in project folder then use +Plugin 'autoload_cscope.vim' " CTRL+\ s searches word under cursor, CTRL+T back +Plugin 'tpope/vim-fugitive' " the most complete GIT integration plugin +Plugin 'taglist-plus' " quick code navigator +let Tlist_Compact_Format = 1 +let Tlist_GainFocus_On_ToggleOpen = 1 +let Tlist_Close_On_Select = 1 +Plugin 'Valloric/YouCompleteMe' | " syntax checker and code completion +let g:ycm_global_ycm_extra_conf = '/home/max/.vim/_ycm_extra_conf.py' | " fallback, right one should be in the applications path +let g:ycm_confirm_extra_conf = 0 | " disable 'do you really want to execute .py?' +let g:ycm_key_select_completion = '' | " key completion key +let g:ycm_error_symbol = '✖' | " insert this as an error symbol in the gutter bar +let g:ycm_warning_symbol = '➔' | " insert this as a warning symbol in the gutter bar +let g:ycm_collect_identifiers_from_tags_files = 1 | " +let g:ycm_autoclose_preview_window_after_insertion=1 | " close the window when leaving insert mode +inoremap ( ( +"if !exists("g:ycm_semantic_triggers") +" let g:ycm_semantic_triggers = {} +"endif +"let g:ycm_semantic_triggers['c'] = ['('] | " + + +call vundle#end() | " required +filetype plugin indent on | " required + +"================================================================================ +" custom config + +set noswapfile | " noundofile, nobackup, nowritebackup +set backupdir=~/.vim/temp | " using :set backup will copy current file to this directory +set directory=~/.vim/temp | " +set undodir=~/.vim/temp | " + +set ts=2 sts=2 sw=2 expandtab | " indentation which i like +set autoindent | " always set autoindenting on +set copyindent | " copy the previous indentation on autoindenting +set scrolloff=2 | " always keeps at least two lines visible (when seeking) + +set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) +set number | " toggle line numbers +set whichwrap=b,s,<,>,[,] | " beyond beginning/end line causes cusor to wrap +set backspace=indent,eol,start| " allow backspacing over everything in insert mode, not needed with whichwrap +set diffopt+=iwhite,filler | " lets diff ignore white spaces +set spell| set spelllang=en,de| " enable spell checker +set showcmd | " displays status line messages while selecting (matrix size) +set breakindent cpoptions+=n | " when wrapping lines indent wrapped line to align with the previews +set linebreak | " do not wrap in the middle of words +set showbreak=› | " symbol used in the beginning of a wrapped line +set listchars=tab:▸\ ,eol:¬ | " symbols used when using :set list (which displays non-printable chars) + + +set virtualedit=onemore " one character beyond the line length should be navigatable (options: all,insert,block,onemore) +nnoremap g$| " and make the key position the cursor after the last char of that line:w + +" search... +set ignorecase|set smartcase " if search pattern contains uppercase then search is case sensitive +set incsearch " do incremental searching +set showmatch|set matchtime=4 " blinks matching braces + +set novisualbell " don't beep +set noerrorbells " don't beep +set guicursor=n-v-c:ver30-Cursor-blinkon500-blinkoff500 " how the caret looks like -filetype plugin indent on -set omnifunc=syntaxcomplete#Complete - -" conceal displays LaTeX formulars inline with UTF8 -set conceallevel=0 " 1,2 to enable it -set concealcursor= - -set linebreak - -"set wrap -set nowrap - -set noswapfile -"set noundofile -"set nobackup -"set nowritebackup -set backupdir=~/.vim/temp -set directory=~/.vim/temp -set undodir=~/.vim/temp - -" [code completion] -set completeopt=longest,menuone - -" [spell checker] -"set spell " enable spell checking -set spelllang=en,de - -set guifont=DejaVu\ Sans\ Mono\ bold\ 11 -"set guifont=Liberation\ Mono\ for\ Powerline\ 11 - - - -" [Kopieren und Einfuegen] -" verwendet das x-window-clipboard <3 -set clipboard=unnamedplus -"set clipboard=autoselectplus - - -" [SUCHEN] -" When 'ignorecase' and 'smartcase' are both on, if a pattern contains an uppercase letter, it is case sensitive, otherwise, it is not. For example, /The would find only "The", while /the would find "the" or "The" etc. -set ignorecase -set smartcase - -" [VIEW] -syntax on - - -" machen, dass der befehl wie z.B. " a p fuer register a -set showcmd -set number - -set guioptions+=m "show menu bar -set guioptions-=T "remove toolbar -set guioptions+=r "show right-hand scroll bar -set guioptions-=c "use console dialogs instead of popups -set guioptions+=a "autoselect: copy&paste using middleclick -set guioptions+=e "add tab pages -set guioptions+=p "use gui pointer callback for x11 - - -" ohne den naechsten eintrag verschwindet die powerline manchmal... -set laststatus=2 - -" set width for indentation -"set tabstop=2 -"set softtabstop=2 -"set shiftwidth=2 -" replace tabstop by space -"set expandtab - -" same in short... -set ts=2 sts=2 sw=2 expandtab - - -let $PAGER='' - -"set =^[[1;2A =^[[1;2B =^[[1;2C =^[[1;2D -"set =^[[24~ -"map -"nnoremap :test -"set =^[9;0011 -" map - -" q: ist der befehlseditor, damit kann man befehle kopieren in den textblock" -" q/ ist die history fuer die letzten suchen -" -" au=auto command, vimenter=event, *=filetype, NERDTree=command -" au vimenter * NERDTree - -"nnoremap :tabnext -"nnoremap :tabpreviews - -"nnoremap :bnext -"nnoremap :bprevious - -"nnoremap -"nnoremap -" -nnoremap :tabnext -nnoremap :tabprevious -" do not display full path as tabname -set guitablabel=%t - -"nnoremap :bnext -"nnoremap :bprevious - -"nnoremap :call s:LaunchCompletion() -"inoremap -nnoremap -"inoremap -inoremap -"inoremap -" open omni completion menu closing previous if open and opening new menu without changing the text -" -" simulate CTRL+C -vnoremap y -"vnoremap d -"noremap gP " interfers with VISUAL BLOCK mode - -" activate visual mode in normal mode -"map V -":map V -" these are mapped in visual mode -"map k -"map j -" increase/decrease indent in visual mode by tab and shift-tab -vmap >gv -vmap OA k -vmap OB j -vmap OC l -vmap OD h -" map shift-right to visually select and so on -nnoremap El -nnoremap vl -nnoremap vj -nnoremap vk -nnoremap vj - -" quickfix list (lists errors and warnings) -" nnoremap :cw -nnoremap :call ToggleQuickfixList() - - -"nnoremap :MBEbf -"nnoremap :MBEbb -nnoremap w -nnoremap W - - -" nnoremap :q -noremap! :w - -"nnoremap :PREVCOLOR -nnoremap :NEXTCOLOR - - -nnoremap ^ -vmap ^ +if has("autocmd") + set modeline " set variables specific to a file, like indentation by adding a comment + set modelines=3 " how many lines in the beginning and end of the file can be mode lines? -nnoremap $ -vmap $ + + augroup resCur | " make cursor appear in its previous position when reopening a file... + "autocmd! + autocmd BufReadPost * call setpos(".", getpos("'\"")) + augroup END -nnoremap \ + augroup PreviewOnBottom | " will open new windows below the current (only in insert mode, so that the preview window is drawn below) + autocmd InsertEnter * set splitbelow + autocmd InsertLeave * set splitbelow! + augroup END -" nnoremap :NERDTreeToggle -nnoremap :browse e -let NERDTreeShowHidden=1 -let NERDTreeQuiToNopen=1 -let NERDChristmasTree=1 -let NERDTreeMinimalUI=1 -let NERDTreeWinSize = 40 -let NERDTreeMapToggleHidden='\h' + augroup OmniFunc | " this will enable omnicomplete just in case this configuration runs somewhere, where YouCompleteMe is not compiled + if exists("+omnifunc") + autocmd Filetype * + \ if &omnifunc == "" | + \ setlocal omnifunc=syntaxcomplete#Complete | + \ setlocal completeopt=longest,menuone | + \ endif + endif + augroup END -" -------------------------------------------------------------------- -let g:airline_left_sep = '▶' -let g:airline_right_sep = '◀' -"let g:airline_theme = 'powerlineish' -"let g:airline_theme = 'tomorrow' -let g:airline_theme = 'light' -let g:airline_powerline_fonts = 1 -if !exists('g:airline_symbols') - let g:airline_symbols = {} + autocmd FileType text setlocal textwidth=78 " text files: set 'textwidth' to 78 + autocmd FileType gitcommit set tw=72 " longer commit messages without auto line wrapping + autocmd FileType LaTeX let g:tex_flavor = "latex" |set conceallevel=1| set concealcursor= endif -let g:airline_symbols.space = "\ua0" - - -let g:miniBufExplAutoStart = 1 -"let g:miniBufExplVSplit = 20 " column width in chars -"let g:miniBufExplBRSplit = 1 " Put new window below -let g:miniBufExplShowBufNumbers = 0 -let g:miniBufExplUseSingleClick = 1 -let g:miniBufExplCycleArround = 1 - let g:miniBufExplMapWindowNavVim = 1 - let g:miniBufExplMapWindowNavArrows = 1 - let g:miniBufExplMapCTabSwitchBufs = 1 - let g:miniBufExplModSelTarget = 1 -" MiniBufExpl Colors -hi MBENormal guifg=fg guibg=bg -hi MBEChanged guifg=red guibg=bg -hi MBEVisibleNormal guifg=bg guibg=fg -hi MBEVisibleChanged guifg=bg guibg=FG -hi MBEVisibleActiveNormal guifg=bg guibg=fg -hi MBEVisibleActiveChanged guifg=bg guibg=fg - -if v:version >= 700 - au BufLeave * let b:winview = winsaveview() - au BufEnter * if(exists('b:winview')) | call winrestview(b:winview) | endif +"================================================================================ +" gui stuff and appearance +if &t_Co > 2 + set hlsearch " + set cursorline " highlight currently selected line endif -" function! PlaySound() -" silent! exec '!play ~/.vim/support/tape.aiff &' -" endfunction -"autocmd CursorMovedI * call PlaySound() - - -set nocompatible -set modeline -set modelines=3 -" vim: syntax=vim -" -" -" -" clang_autocomplete options - - -let g:clang_use_library=1 -"let g:clang_library_path='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib' -let g:clang_auto_select=0 -let g:clang_complete_auto=1 " automatically complete after ->, ., :: -let g:clang_periodic_quickfix=1 -let g:clang_close_preview=1 " If equal to 1, the preview window will be close automatically after a completion -"let g:clang_snippets=1 -"let g:clang_conceal_snippets=1 -"let g:clang_snippets_engine='clang_complete' -"let g:clang_complete_macros=1 -"let g:clang_complete_patterns=1 -"let g:clang_close_preview=1 - -" Show clang errors in the quickfix window -"let g:clang_complete_copen = 1 -" -" -let g:clang_user_options='|| exit 0' -let g:clang_sort_algo="alpha" - - - -" muss am ende stehen, macht das INSERT nicht angezeigt wird. macht ja airline -" auch schon. -set noshowmode " hide --INSERT-- from command line (as its already shown in airline) -set cursorline " highlight currently selected line - -set wildmenu " displays command options in status line / airline when pressing TAB -set wildmode=longest:full,full - -set scrolloff=2 " always keep at least two lines visible (when seeking) - -"noremap help vert help -cabbrev help tab help -"autocmd FileType help,* wincmd L - -"autocmd BufNew * if winnr('$') == 1 | tab sball | endif -"autocmd BufReadPost * tab ball -map ,e :e =expand("%:p:h") . "/" - -" If wanted, auto commenting can be disabled for all files with: -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o +if has('mouse') + set mouse=a +endif -colorscheme maxvb6 if has("gui_running") - "colorscheme Tomorrow-Night-Blue - "colorscheme bclear + set guitablabel=%t " do not display full path as tabname + set guioptions+=m " menu bar + set guioptions+=T " toolbar + set guioptions+=r " right-hand scroll bar + set guioptions-=c " use console dialogs instead of popups + set guioptions+=a " autoselect: copy&paste using middleclick + set guioptions+=e " add tab pages + set guioptions+=p " use gui pointer callback for x11 + set toolbariconsize=large " make the icon toolbar as big as possible else - " use 256 colors in Console mode if we think the terminal supports it if &term =~? 'mlterm\|xterm\|screen' - set t_Co=256 + set t_Co=256 | " fixes incompatibilities with our color scheme endif - "set t_Co=256 - "set t_AB=^[[48;5;%dm - "set t_AF=^[[38;5;%dm - "set term=ansi - "colorscheme ibmedit - "colorscheme h80 - "colorscheme greyhouse - "colorscheme tango-morning - "colorscheme jhlight - "colorscheme newspaper - "colorscheme relaxedgreen - let g:airline_theme = 'hybrid' - "highlight LineNr ctermfg=grey ctermbg=black + set title | " set the terminal caption + set titleold="vim ended" | " set terminal title after closing vim + set titlestring="VIM-CONSOLE" | " set window title + set icon | " sets the terminal icon to vim + set ttyfast | " modern terminals are all fast in a way endif - -" ex command for toggling hex mode - define mapping if desired -command -bar Hexmode call ToggleHex() - -" helper function to toggle hex mode -function ToggleHex() - " hex mode should be considered a read-only operation - " save values for modified and read-only for restoration later, - " and clear the read-only flag for now - let l:modified=&mod - let l:oldreadonly=&readonly - let &readonly=0 - let l:oldmodifiable=&modifiable - let &modifiable=1 - if !exists("b:editHex") || !b:editHex - " save old options - let b:oldft=&ft - let b:oldbin=&bin - " set new options - setlocal binary " make sure it overrides any textwidth, etc. - let &ft="xxd" - " set status - let b:editHex=1 - " switch to hex editor - %!xxd - else - " restore old options - let &ft=b:oldft - if !b:oldbin - setlocal nobinary - endif - " set status - let b:editHex=0 - " return to normal editing - %!xxd -r - endif - " restore values for modified and read only state - let &mod=l:modified - let &readonly=l:oldreadonly - let &modifiable=l:oldmodifiable -endfunction - - -" Show syntax highlighting groups for word under cursor -map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' - \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" - \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" - - -" Append modeline after last line in buffer using \ml -" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX -" files. -function! AppendModeline() - let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", - \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') - let l:modeline = substitute(&commentstring, "%s", l:modeline, "") - call append(line("$"), l:modeline) -endfunction -nnoremap ml :call AppendModeline() - - -" make vimdiff ignore white spaces -set diffopt+=iwhite -set diffopt+=filler -set diffexpr="" -set nocompatible - - -set diffopt+=iwhite - - -set guicursor=n-v-c:ver30-Cursor-blinkon500-blinkoff500 -highlight Cursor guifg=black guibg=lightgreen - - - -set virtualedit=onemore -" damit das highlight der klammern nicht genauso aussieht wie der cursor -hi MatchParen cterm=none ctermbg=yellow ctermfg=yellow - - -" An example for a vimrc file. +colorscheme maxvb6 +syntax enable + +"================================================================================ +" plugin hotkeys +nnoremap :TlistToggle| " bind TagList to Hotkey Ctrl+L + +" code completion: http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE +" reacts on CTRL+P, CTRL+Space +inoremap pumvisible() ? "\" : "\u\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\\\" : "\" +inoremap pumvisible() ? "\\\" : "\" + +" custom commands... +cmap w!! w !sudo tee % >/dev/null| " write :w!! to execute :w as root user + +" custom hotkeys... +nnoremap :tabnext| " lets one use CTRL+Tab to switch between tabs +nnoremap :tabprevious| " use CTRL+Shift+Tab to switch to preview tab +nnoremap j gj|nnoremap k gk| " do not jump over wrapped lines... +map h|map j|map k|map l| " window navigation shortcut + + +"================================================================================ +" deactivated on-demand commands (just in case one needs them one day) +" set guiheadroom=0| " do not fill non-functional area of the empty editor with gtk background +" map shift-right to visually select and so on +"nnoremap El +"nnoremap vl +"nnoremap vj +"nnoremap vk +"nnoremap vj +" noremap % v% " jump between braces and highlight +"nnoremap ^ +"vmap ^ +"nnoremap $ +"vmap $ +"nnoremap +"nnoremap +":inoremap pumvisible() ? "\" : "\u\" +"map OA k|map OB j|map OC l|map OD h| " allow cursor keys in insert mode " -" Maintainer: Bram Moolenaar -" Last change: 2014 Nov 05 +"inoremap pumvisible() ? "\" : "\" " breaks cursor keys! +" binding ESC can easily break cursor key movement on the console (tricky, because gvim works) " -" To use it, copy it to -" for Unix and OS/2: ~/.vimrc -" for Amiga: s:.vimrc -" for MS-DOS and Win32: $VIM\_vimrc -" for OpenVMS: sys$login:.vimrc - -" When started as "evim", evim.vim will already have done these settings. -if v:progname =~? "evim" - finish -endif - -" Use Vim settings, rather than Vi settings (much better!). -" This must be first, because it changes other options as a side effect. -set nocompatible - -" allow backspacing over everything in insert mode -set backspace=indent,eol,start - -if has("vms") - set nobackup " do not keep a backup file, use versions instead -else - set backup " keep a backup file (restore to previous version) - set undofile " keep an undo file (undo changes after closing) -endif -set history=50 " keep 50 lines of command line history -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set incsearch " do incremental searching - -" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries -" let &guioptions = substitute(&guioptions, "t", "", "g") - -" Don't use Ex mode, use Q for formatting -map Q gq - -" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, -" so that you can undo CTRL-U after inserting a line break. -inoremap u - -" In many terminal emulators the mouse works just fine, thus enable it. -if has('mouse') - set mouse=a -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 - -" Only do this part when compiled with support for autocommands. -if has("autocmd") - - " Enable file type detection. - " Use the default filetype settings, so that mail gets 'tw' set to 72, - " 'cindent' is on in C files, etc. - " Also load indent files, to automatically do language-dependent indenting. - filetype plugin indent on - - " Put these in an autocmd group, so that we can delete them easily. - augroup vimrcEx - au! - - " For all text files set 'textwidth' to 78 characters. - autocmd FileType text setlocal textwidth=78 - - " When editing a file, always jump to the last known cursor position. - " Don't do it when the position is invalid or when inside an event handler - " (happens when dropping a file on gvim). - " Also don't do it when the mark is in the first line, that is the default - " position when opening a file. - autocmd BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif - - augroup END - -else - - set autoindent " always set autoindenting on - -endif " has("autocmd") - -" Convenient command to see the difference between the current buffer and the -" file it was loaded from, thus the changes you made. -" Only define it when not defined already. -if !exists(":DiffOrig") - command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis - \ | wincmd p | diffthis -endif - -if has('langmap') && exists('+langnoremap') - " Prevent that the langmap option applies to characters that result from a - " mapping. If unset (default), this may break plugins (but it's backward - " compatible). - set langnoremap -endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" An example for a vimrc file. " -" Maintainer: Bram Moolenaar -" Last change: 2014 Nov 05 " -" To use it, copy it to -" for Unix and OS/2: ~/.vimrc -" for Amiga: s:.vimrc -" for MS-DOS and Win32: $VIM\_vimrc -" for OpenVMS: sys$login:.vimrc - -" When started as "evim", evim.vim will already have done these settings. -if v:progname =~? "evim" - finish -endif - -" Use Vim settings, rather than Vi settings (much better!). -" This must be first, because it changes other options as a side effect. -set nocompatible - -" allow backspacing over everything in insert mode -set backspace=indent,eol,start - -if has("vms") - set nobackup " do not keep a backup file, use versions instead -else - set backup " keep a backup file (restore to previous version) - set undofile " keep an undo file (undo changes after closing) -endif -set history=50 " keep 50 lines of command line history -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set incsearch " do incremental searching - -" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries -" let &guioptions = substitute(&guioptions, "t", "", "g") - -" Don't use Ex mode, use Q for formatting -map Q gq -" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, -" so that you can undo CTRL-U after inserting a line break. -inoremap u - -" In many terminal emulators the mouse works just fine, thus enable it. -if has('mouse') - set mouse=a -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 - -" Only do this part when compiled with support for autocommands. -if has("autocmd") - - " Enable file type detection. - " Use the default filetype settings, so that mail gets 'tw' set to 72, - " 'cindent' is on in C files, etc. - " Also load indent files, to automatically do language-dependent indenting. - filetype plugin indent on - - " Put these in an autocmd group, so that we can delete them easily. - augroup vimrcEx - au! - - " For all text files set 'textwidth' to 78 characters. - autocmd FileType text setlocal textwidth=78 - - " When editing a file, always jump to the last known cursor position. - " Don't do it when the position is invalid or when inside an event handler - " (happens when dropping a file on gvim). - " Also don't do it when the mark is in the first line, that is the default - " position when opening a file. - autocmd BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif - - augroup END - -else - - set autoindent " always set autoindenting on - -endif " has("autocmd") - -" Convenient command to see the difference between the current buffer and the -" file it was loaded from, thus the changes you made. -" Only define it when not defined already. -if !exists(":DiffOrig") - command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis - \ | wincmd p | diffthis -endif - -if has('langmap') && exists('+langnoremap') - " Prevent that the langmap option applies to characters that result from a - " mapping. If unset (default), this may break plugins (but it's backward - " compatible). - set langnoremap -endif +"inoremap +"inoremap -- cgit v1.2.3