Files
dotfiles/.vimrc

92 lines
2.8 KiB
VimL
Executable File

set nocompatible " be iMproved, required
filetype off " required
let vundle_dir="~/.vim/bundle/Vundle.vim"
if filereadable(expand(vundle_dir) . "/README.md")
" set the runtime path to include Vundle and initialize
let &rtp .= "," . vundle_dir
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'scrooloose/nerdtree'
Plugin 'c.vim'
Plugin 'jeetsukumaran/vim-buffergator'
Plugin 'ericcurtin/CurtineIncSw.vim'
Plugin 'tpope/vim-fugitive'
" Plugin 'tpope/vim-surround'
Plugin 'ctrlpvim/ctrlp.vim'
" Plugin 'shougo/neocomplete'
Plugin 'godlygeek/tabular'
call vundle#end() " required
else
let vundle_repo="https://github.com/VundleVim/Vundle.vim.git"
echo "Vundle not installed, type :CloneVundle to clone the vundle repo"
command CloneVundle execute "!git clone " . vundle_repo . " " . vundle_dir
endif
filetype plugin indent on " required
syntax on
set tabstop=4 " show existing tab with 4 spaces width
set shiftwidth=4 " when indenting with '>', use 4 spaces width
set expandtab " On pressing tab, insert 4 spaces
set mouse=a
set nu
" define upper case versions of :w and :q
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>
" fugitive.vim looks for tags in .git
" set tags +=~/tags " Recursively move upwards in tree, searching in subfolders for tags file
if exists(":NERDTree")
" Open NERDTree if no file specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
endif
" CtrlP
let g:ctrlp_working_path_mode = 'ra'
" Find project root
let git_dir_location=finddir('.git', ';')
let git_root_location=fnamemodify(git_dir_location, ':h')
" Locate cscope file
if has("cscope")
set csto=0 " Search cscope before ctags
set cst " <C-]> searches cscope also
set nocsverb " Not verbose when adding database
set cspc=3 " Display the last 3 components of file path
"add any database in current dir
if filereadable("cscope.out")
cs add cscope.out
"else search cscope.out in git folder
else
let cscope_file=findfile("cscope.out", git_dir_location)
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file git_root_location
endif
endif
endif
command! Csc cscope find c <cword>
" Regen cscope
" sh ~/bin/gen_cscope.sh . .git/cscope.out
"
" Key binds
"
nmap <F2> :NERDTreeToggle<CR>
nmap <F3> :NERDTreeFind<CR>
map <F5> :call CurtineIncSw()<CR>
nmap <F8> :silent !/home/efjtjkb/bin/comp<enter>
" Remap <F9> (c-vim uses this)
"nmap <F9> :silent !/home/efjtjkb/bin/run<enter>
autocmd VimEnter * noremap <F9> :silent !/home/efjtjkb/bin/run<enter>
nmap <F10> :silent !/home/efjtjkb/bin/run old<enter>