Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- colorscheme koehler
- syntax on
- set nowrap
- set tabstop=2
- set expandtab
- set shiftwidth=2
- set smartindent
- set noswapfile
- set undodir=~/.vimdir/undodir
- set undofile
- set history=9999
- set hidden
- " Put plugins and dictionaries in this dir (also on Windows)
- let vimDir = '$HOME/.vim'
- if stridx(&runtimepath, expand(vimDir)) == -1
- " vimDir is not on runtimepath, add it
- let &runtimepath.=','.vimDir
- endif
- " Keep undo history across sessions by storing it in a file
- if has('persistent_undo')
- let myUndoDir = expand(vimDir . '/undodir')
- " Create dirs
- call system('mkdir ' . vimDir)
- call system('mkdir ' . myUndoDir)
- let &undodir = myUndoDir
- set undofile
- endif
- " set guifont=Lucida_Console:h9:cANSI
- " Set the search scan to wrap around the file
- set wrapscan
- " Make command line two lines high
- set ch=2
- " Allow backspacing over indent, eol, and the start of an insert
- set backspace=2
- " See :help 'cpoptions' for these ones. 'cpoptions' has a huge
- " set of possible options
- set cpoptions=ces$
- " Set the status line the way I like it
- set stl=%f\ %m\ %r\ Line:\ %l/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%b][0x%B]
- " tell Vim to always put a status line in, even if there is only one
- " window
- set laststatus=2
- set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
- " Hide the mouse pointer while typing
- set mousehide
- " This is the timeout used while waiting for user input on a
- " multi-keyed macro or while just sitting and waiting for another
- " key to be pressed measured in milliseconds.
- "
- " i.e. for the ",d" command, there is a "timeoutlen" wait
- " period between the "," key and the "d" key. If the
- " "d" key isn't pressed before the timeout expires,
- " one of two things happens: The "," command is executed
- " if there is one (which there isn't) or the command aborts.
- "
- " The idea here is that if you have two commands, say ",dv" and
- " ",d" that it will take 'timeoutlen' milliseconds to recognize
- " that you're going for ",d" instead of ",dv"
- "
- " In general you should endeavour to avoid that type of
- " situation because waiting 'timeoutlen' milliseconds is
- " like an eternity.
- set timeoutlen=500
- " Keep some stuff in the history
- set history=1000
- " These commands open folds
- set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
- " When the page starts to scroll, keep the cursor 8 lines from
- " the top and 8 lines from the bottom
- set scrolloff=8
- " Allow the cursor to go in to "invalid" places
- "set virtualedit=all
- " For how *I* code these are the best types of settings for
- " completion but I get rid of some neat things that you might
- " like
- set complete=.,w,b,t
- " Incrementally match the search. I orignally hated this
- " but someone forced me to live with it for a while and told
- " me that I would grow to love it after getting used to it...
- " turns out he was right :)
- set incsearch
- " Syntax coloring lines that are too long just slows down the world
- set synmaxcol=2048
- map :bnext <CR>
- map :bprev <CR>
- :hi StatusLine ctermbg=red ctermfg=green
- "set showcmd
- "fun! TrimWhitespace()
- " let l:save = winsaveview()
- " %s/\s\+$//e
- " call winrestview(l:save)
- "endfun
- "autocmd BufWritePre * :call TrimWhitespace()
- filetype plugin indent on
- :set hidden
- :set confirm
- set ts=2
- set sw=2
- :autocmd Filetype c set ts=4
- :autocmd Filetype c set sw=4
- " Auto-format C++ files to 2-space tabs on open
- function! AutoFormat2Spaces()
- " Only for C++ files
- if &filetype == 'cpp' || expand('%:e') =~ '^\(cpp\|hpp\|h\|cc\|cxx\)$'
- " Save cursor position
- let l:save = winsaveview()
- " Set to 2-space tabs
- setlocal ts=2 sw=2 et
- " Reindent the entire file
- normal! gg=G
- " Restore cursor position
- call winrestview(l:save)
- endif
- endfunction
- syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
- syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
- hi Oddlines ctermfg=white
- hi Evenlines ctermfg=grey
- set visualbell
- set t_vb=
- vnoremap <C-g> :norm
- autocmd FileType * set formatoptions-=o
- autocmd FileType * set formatoptions-=r
- highlight jsonString ctermfg=196 cterm=bold
- highlight Comment ctermfg=green
- noremap <S-q> <Nop>
- map <S-:> <Nop>
- " Enable Ctrl-C and Ctrl-V for copy and paste
- " Visual mode: Ctrl-C to copy
- vnoremap <C-c> "+y
- " Normal mode: Ctrl-V to paste after cursor
- "nnoremap <C-v> "+p
- " Visual mode: Ctrl-V to paste (replace selection)
- "vnoremap <C-v> "+p
- " Insert mode: Ctrl-V to paste
- "inoremap <s-C-v> <Esc>"+pa
- " ============================================================================
- " libeen-cpp project ctags configuration
- " ============================================================================
- " Auto-load libeen-cpp tags from repository root, build, and install locations
- set tags+=./tags,./build/tags,./build_local/tags,/usr/local/share/libeen-cpp/tags,/usr/share/libeen-cpp/tags,/opt/een/share/libeen-cpp/tags
- " Function to load cscope database if it exists
- function! LoadLibeenCscopeDB()
- " Try build directory first
- if filereadable("build/cscope.out")
- cs add build/cscope.out
- elseif filereadable("build_local/cscope.out")
- cs add build_local/cscope.out
- " Try installed location
- elseif filereadable("/usr/local/share/libeen-cpp/cscope.out")
- cs add /usr/local/share/libeen-cpp/cscope.out
- elseif filereadable("/usr/share/libeen-cpp/cscope.out")
- cs add /usr/share/libeen-cpp/cscope.out
- elseif filereadable("/opt/een/share/libeen-cpp/cscope.out")
- cs add /opt/een/share/libeen-cpp/cscope.out
- endif
- endfunction
- " Load cscope database on startup if available
- if has("cscope")
- set csprg=/usr/bin/cscope
- set csto=0
- set cst
- set nocsverb
- " Load project-specific database
- call LoadLibeenCscopeDB()
- set csverb
- endif
- " Function to find project root (looks for CMakeLists.txt)
- function! FindLibeenProjectRoot()
- let root = findfile("CMakeLists.txt", ".;")
- if !empty(root)
- let rootdir = fnamemodify(root, ":p:h")
- " Check if this is libeen-cpp project
- if filereadable(rootdir . "/libs/core/een++/core.h")
- return rootdir
- endif
- endif
- return ""
- endfunction
- " Auto-load tags based on project root when entering libeen-cpp project
- function! AutoLoadLibeenTags()
- let root = FindLibeenProjectRoot()
- if !empty(root)
- " Add build/tags relative to project root
- exe "set tags+=" . root . "/build/tags"
- exe "set tags+=" . root . "/build_local/tags"
- " Try to load cscope from project root
- if has("cscope") && filereadable(root . "/build/cscope.out")
- exe "cs add " . root . "/build/cscope.out " . root
- endif
- endif
- endfunction
- " Call when entering a buffer
- autocmd BufEnter *.cpp,*.hpp,*.h,*.ipp call AutoLoadLibeenTags()
- " Cscope key mappings for quick navigation
- " Find symbol
- nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
- " Find definition
- nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
- " Find functions calling this function
- nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
- " Find functions called by this function
- nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
- set cursorline
Advertisement
Add Comment
Please, Sign In to add comment