Skip to content

Instantly share code, notes, and snippets.

@darrnshn
Last active September 15, 2015 10:09
Show Gist options
  • Select an option

  • Save darrnshn/da3d87d03d5ba7a826be to your computer and use it in GitHub Desktop.

Select an option

Save darrnshn/da3d87d03d5ba7a826be to your computer and use it in GitHub Desktop.
Vimrc
" vundle
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'kien/ctrlp.vim' " navigate folders
Plugin 'rking/ag.vim' " search code
Plugin 'justinmk/vim-sneak' " jump around
Plugin 'tpope/vim-surround' " edit surroundings
Plugin 'tpope/vim-repeat' " repeat all the things
Plugin 'mtth/scratch.vim' " scratch pad
Plugin 'kien/rainbow_parentheses.vim' " rainbows!
Plugin 'sjl/gundo.vim' " undo/redo
Plugin 'takac/vim-hardtime' " don't be lazy
call vundle#end()
filetype plugin indent on
" use comma for leader key
let mapleader=","
" CtrlP plugin
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_match_window = 'bottom,order:ttb'
let g:ctrlp_switch_buffer = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag plugin
nnoremap <Leader>a :Ag
vnoremap <Leader>a y:Ag <C-R>"<CR>
" vimsneak plugin
let g:sneak#use_ic_scs = 1 " case insensitive
let g:sneak#streak = 1
" surround plugin
let g:surround_no_mappings = 1
xmap <Leader>s <Plug>VSurround
" scratch pad plugin
nnoremap <Leader>S :Scratch<CR>
" rainbow plugin
nnoremap <Leader>r :RainbowParenthesesToggle<CR>
let g:rbpt_colorpairs = [
\ ['red', 'firebrick3'],
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ]
" gundo plugin
nnoremap ,g :GundoToggle<CR>
" dard time
let g:hardtime_default_on = 0
let g:list_of_normal_keys = ["h", "j", "k", "l", "-", "+", "<UP>", "<DOWN>", "<LEFT>", "<RIGHT>", "w", "W", "b", "B", "e", "E"]
let g:list_of_visual_keys = ["h", "j", "k", "l", "-", "+", "<UP>", "<DOWN>", "<LEFT>", "<RIGHT>", "w", "W", "b", "B", "e", "E"]
let g:list_of_insert_keys = ["<UP>", "<DOWN>", "<LEFT>", "<RIGHT>"]
let g:hardtime_showmsg = 1
" use the Solarized color scheme for syntax highlighting
syntax enable
set background=light
colorscheme solarized
filetype on
" use C++11 syntax file
au BufNewFile,BufRead *.cpp set syntax=cpp11
au BufNewFile,BufRead *.hpp set syntax=cpp11
au BufNewFile,BufRead *.h set syntax=cpp11
set showmode " show visual/normal/insert mode
set cursorline " highlight current line
set nu " show line numbers
set ignorecase " ignore case in searches
set incsearch " incremental search
set hlsearch " highlight searches
set ruler " show cursor position
set lazyredraw " possible optimization?
set hidden " don't close buffers
set wildmenu " autocomplete filenames
set wildignore=*.swp,*.bak,*.pyc,*.class " ignore certain files
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
" folding
set foldenable
set foldlevelstart=99
set foldnestmax=10
set foldmethod=indent
nnoremap <space> za
" 2 space indenting
set autoindent
if has("autocmd")
filetype plugin indent on
endif
set expandtab
set smarttab
set shiftwidth=2
set softtabstop=2
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" 4 space indent for Python code
autocmd FileType python set tabstop=8|set shiftwidth=4|set expandtab
" 8 space indent for C code
autocmd FileType c set tabstop=8|set shiftwidth=8|set expandtab
" quicker way to exit to normal mode
inoremap jk <Esc>
" type {{ to open new code block
inoremap {{ {<CR>}<Esc>O
" faster save
nnoremap <leader>w :w!<CR>
" underscore text object
vnoremap i_ <Esc>T_vt_
vnoremap a_ <Esc>F_vf_
onoremap i_ :normal vi_<CR>
onoremap a_ :normal va_<CR>
" toggle paste using F2
set pastetoggle=<F2>
" clear search using //
nmap <silent> // :nohlsearch<CR>
" switch header and cpp
nnoremap Q :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
" highlight trailing space
set list
set listchars=trail:·
" Don't really want to accidentally open man page
map <S-k> <Nop>
" Buffer movement
map <Tab> :bnext<CR>
map <S-Tab> :bprevious<CR>
" Highlight text past column 80
augroup vimrc_autocmds
autocmd BufEnter * highlight OverLength ctermbg=red ctermfg=white guibg=#592929
autocmd BufEnter * match OverLength /\%81v.\+/
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment