Skip to content

Instantly share code, notes, and snippets.

@mjacobs
Last active August 24, 2017 16:14
Show Gist options
  • Save mjacobs/3eaae68cb533747c3396 to your computer and use it in GitHub Desktop.
Save mjacobs/3eaae68cb533747c3396 to your computer and use it in GitHub Desktop.
mj's vimrc
" Matthew Jacobs
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'gmarik/vundle'
Plugin 'bufexplorer.zip'
Plugin 'xolox/vim-misc'
Plugin 'mru.vim'
Plugin 'taglist.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'cscope_macros.vim'
Plugin 'a.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlp.vim'
Plugin 'techlivezheng/vim-plugin-minibufexpl'
Plugin 'drmikehenry/vim-fontsize'
Plugin 'bling/vim-airline'
Plugin 'majutsushi/tagbar'
Plugin 'solarnz/thrift.vim'
Plugin 'jamessan/vim-gnupg'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips' " seems to be required
"Plugin 'jreybert/vimagit'
"Bundle 'altercation/vim-colors-solarized'
"Bundle 'xolox/vim-easytags' // Issue loading some xolox function
"Bundle 'python.vim' // Adds annoying keybindings ']c' used for vimdiff
"Bundle 'terryma/vim-multiple-cursors'
"Bundle 'minibufexpl.vim'
"Bundle 'L9'
"Bundle 'FuzzyFinder'
filetype plugin indent on
set backup
if has("win32")
set guifont=Consolas:h9
set bdir=$TEMP
set dir=$TEMP
elseif has("unix")
set bdir=/tmp
set dir=/tmp
let s:uname = system("uname")
" Special handling for osx
if s:uname == "Darwin"
" Specify ctags location for Taglist
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
" Disable YCM on mac
"set runtimepath-=~/.vim/bundle/YouCompleteMe/
else
set guifont=Source\ Code\ Pro\ Medium\ 9
endif
endif
"source $VIMRUNTIME/mswin.vim
"behave mswin
" General behavor
set history=1000 " History to remember
set autoread " Autoload changes
set wildmenu " Full completion menu features
set hidden " Do not ask for saving on buf switch
set backspace=2
" Looknfeel
set t_Co=256 " set the number of terminal colors
"set background=dark
"let g:solarized_termcolors=256
"colorscheme solarized
colorscheme molokai " choose color scheme
set number " shows line number to left
set ruler " shows line number and char number on status bar
set novb " no visual bell
set noeb " no error bells
set t_vb= " turn off annoying visual bell
set mouse=a " use mouse
" status: [filename] [write?] Line:l/total[%] Col:[c] Buf:[b][ascii][hex]
set laststatus=2
set statusline=%f\ %m\ %r\ Line:%l/%L[%p%%]\ Col:%c\ Buf:%n\ [%b][0x%B]\ %{fugitive#statusline()}
" Buffer switching
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>p :bp<CR>
nnoremap <Leader>n :bn<CR>
" Tab switching
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
" Remove trailing whitespace
nnoremap <Leader>rtw :%s/\s\+$//e<CR>
" Syntax/filetype
syntax enable
set showmatch " Matching braces
set autoindent " Copy indent from current line when start new line
" Filetype specific settings
au FileType gpg set tw=60
au FileType gitcommit set tw=60 spell
" Tabbing
set expandtab " Use spaces instead of tabs
set shiftwidth=2 " Number of spaces to use for each step of auto indent
set softtabstop=2 " Number of spaces that a <Tab> counts for in editing
" NOTE tabstop is not set
" Wrapping
set wrap
set showbreak=>>>
set textwidth=89
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
" Searching
set ignorecase " Not case sensitive
set smartcase " Case sensitive if search has caps
set hlsearch " Highlight search
set incsearch " Search incrementally
" Spelling
set spellfile=~/.vim/spell/en.utf-8.add
" C++
" Jump to the next/previous method
"nnoremap <M-J> /\v^(\w+\s+)?\w+::\w+\(.*\)
"nnoremap <M-K> ?\v^(\w+\s+)?\w+::\w+\(.*\)
" Add /// comments
autocmd Filetype c,cpp set comments^=:///
command! C let @/=""
" Cut/copy/paste mappings
"vnoremap <C-X> "+x
"vnoremap <C-C> "+y
"map <C-V> "+gP
"cmap <C-V> <C-R>+
" Copy the file name/full path to the clipboard: ',cs', ',cl', respectively
if has('win32')
" Convert slashes to backslashes for Windows.
nmap ,cs :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
nmap ,cl :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>
" This will copy the path in 8.3 short format, for DOS and Windows 9x
nmap ,c8 :let @*=substitute(expand("%:p:8"), "/", "\\", "g")<CR>
else
" Works for gnome clipboard (i.e. use @+ register instead of @*)
nmap ,cs :let @+=expand("%")<CR>
nmap ,cl :let @+=expand("%:p")<CR>
" For X clipboard
"nmap ,cs :let @*=expand("%")<CR>
"nmap ,cl :let @*=expand("%:p")<CR>
endif
" MiniBufExpl
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Tagbar
let g:tagbar_left = 1
" Variables used for :TOhtml
let use_xhtml = 1
let html_use_css = 1
let html_number_lines = 0
" Map F8 to toggle tag list
"nnoremap <silent> <F8> :TlistToggle<CR>
nnoremap <silent> <F8> :TagbarToggle<CR>
" Map F9 to toggle NERDTree
nnoremap <silent> <F9> :NERDTree<CR>
" Map <leader>v to edit .vimrc
nnoremap <Leader>v :e ~/.vimrc<CR>
" Map <leader>r to reload .vimrc
nnoremap <Leader>r :source ~/.vimrc<CR>
" Toggle spell checking with <F5>
nnoremap <F5> :setlocal spell! spelllang=en_us<CR>
" Insert date/time with F6
nnoremap <F6> "=strftime("%c")<CR>P
inoremap <F6> <C-R>=strftime("%c")<CR>
" Alternate
nnoremap <silent> so :A<CR>
nnoremap <silent> sp :AS<CR>
nnoremap <silent> sv :AV<CR>
" BufExplorer
nnoremap <silent> q :BufExplorer<CR>
" FuzzyFink
"let g:fuf_mrufile_maxItem = 400
"let g:fuf_mrucmd_maxItem = 400
"nnoremap <silent> sj :FufBuffer<CR>
"nnoremap <silent> sk :FufFileWithCurrentBufferDir<CR>
"nnoremap <silent> sK :FufFileWithFullCwd<CR>
"nnoremap <silent> s<C-k> :FufFile<CR>
"nnoremap <silent> st :FufTag<CR>
"nnoremap <silent> s, :FufBufferTag<CR>
"nnoremap <silent> s. :FufBufferTagAll<CR>
"nnoremap <silent> sh :FufHelp<CR>
"nnoremap <silent> sr :FufRenewCache<CR>
" Syntax
au BufRead,BufNewFile *.cpp,*.cc,*.h setlocal filetype=cpp
au BufRead,BufNewFile *.y setlocal filetype=cup
au BufRead,BufNewFile *.py setlocal filetype=python
au BufRead,BufNewFile *.avdl setlocal filetype=avro-idl
au BufRead,BufNewFile *.thrift setlocal filetype=thrift
au! Syntax thrift source ~/.vim/thrift.vim
" Alternate
let g:alternateExtensions_cc = "h"
let g:alternateExtensions_h = "cc,cpp"
" Ctrl-P
" Ignore binaries in wildignore
set wildignore+=*.o,*.so,*.class,*.jar,*.dat,*.pyc,*.bin,*/build/*,*/CMakeFiles/*,*/cluster_logs/*,*/cdh-4-hdfs-data/*,*/cdh-5-hdfs-data/*,*/testdata/cluster/*
let g:ctrlp_max_files=0 " No limit on files
" YCM settings
let g:ycm_extra_conf_globlist = ['~/tmp/*','~/dev/Impala/*']
" Eclim settings
let g:EclimCompletionMethod = 'omnifunc'
" libclang settings
"let g:clang_use_library = 1
"let g:clang_library_path = "/home/mj/dev/llvm-3.3.src/Release+Asserts/lib/"
" Highlight column 80 to find long lines
set cc=90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment