Skip to content

Instantly share code, notes, and snippets.

@introom
Created March 21, 2014 13:52
Show Gist options
  • Save introom/9686734 to your computer and use it in GitHub Desktop.
Save introom/9686734 to your computer and use it in GitHub Desktop.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
Bundle 'Raimondi/delimitMate'
Bundle 'SirVer/ultisnips'
Bundle 'Valloric/YouCompleteMe'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-repeat'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'kien/ctrlp.vim'
Bundle 'sjl/gundo.vim'
Bundle 'bling/vim-airline'
Bundle 'rking/ag.vim'
Bundle 'benmills/vimux'
Bundle 'guns/xterm-color-table.vim'
filetype plugin indent on
" BELOW BEGINS MY OWN SETUP
" gui settings
if has('gui_running')
set guifont=Monaco:h14
set background=dark
set guioptions-=rL
colorscheme slate
else
colorscheme desert
endif
let g:mapleader = '\'
let g:maplocalleader = '-'
" quick way to modify $MYVIMRC
nnoremap <silent> <leader>ev :split $MYVIMRC<CR>
nnoremap <silent> <leader>sv :source $MYVIMRC<CR>
" quick way to toggle paste option
nnoremap <silent> <leader>p :set paste!<CR>
syntax enable
set nu
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set autoindent
set smartindent
set wrap
set ruler
set scrolloff=3
set ignorecase
set smartcase
set hlsearch
set incsearch
set cursorline
set showcmd
" set showmatch
set matchtime=1
set autowrite
set wildmenu
set wildignore=*.o,*~,*.pyc
set hidden
set splitbelow
set visualbell t_vb=
set completeopt-=preview
set noerrorbells
set ttimeoutlen=30
" no mouse support
set mouse=
" set the width of netrw
let g:netrw_winsize=-25
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
noremap <silent> <C-l> :nohl<CR><C-l>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
" delete one character from right
inoremap <C-l> <Del>
" adjust window size
nnoremap <silent> <Leader>= 3<C-w>+:silent! call repeat#set("\<Leader>=")<CR>
nnoremap <silent> <Leader>- 3<C-w>-:silent! call repeat#set("\<Leader>-")<CR>
nnoremap <silent> <Leader>, 5<C-w><:silent! call repeat#set("\<Leader>,")<CR>
nnoremap <silent> <Leader>. 5<C-w>>:silent! call repeat#set("\<Leader>.")<CR>
" open a new file
nnoremap <silent> gn :new<Bar>only<CR>
" shortcut to session folder
cnoremap <C-s> ~/.vim/.sessions/
" system clipboard copy
vnoremap <leader>y "*y
" persisent undo
set undodir=~/.vim/.undo/
set undofile
set undolevels=1000
set undoreload=10000
" delete all trailing whitespace
nnoremap <silent> <leader>t :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>``<C-l>:w<CR>
" change cwd to the file opened
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
" turn to upper case, useful for constant names
" inoremap <C-u> <ESC>viWUEa
" write file with root permission
command! Rw execute "% !sudo tee >/dev/null " . expand("%")
" save file
nnoremap <D-s> :w<CR>
" jump to the current error
nnoremap <leader>l :<C-u>ll<CR>
" highlight customs
highlight MatchParen cterm=NONE ctermbg=NONE ctermfg=red
highlight Visual cterm=NONE ctermbg=23
highlight Search cterm=NONE ctermfg=0 ctermbg=202
highlight IncSearch cterm=NONE ctermfg=0 ctermbg=202
" we don't wanna highlight the line background
" we just want the line number
highlight clear CursorLine
"""""""""""""""""""""""""""""""""""the"""best"""split"""line"""ever"""""""""""""""
" HERE GOES SOME UTILITY FUNCTIONS
function! s:get_visual_selection()
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][col1 - 1:]
return join(lines, "\n")
endfunction
"""""""""""""""""""""""""""""""""""the"""best"""split"""line"""ever"""""""""""""""
" HERE GOES PLUGIN SETTINGS
" NerdTree settings
nnoremap <silent> <leader><F2> :NERDTreeToggle<CR>
" Gundo settings
nnoremap <silent> <leader><F3> :GundoToggle<CR>
" YouCompleteMe settings
let g:ycm_global_ycm_extra_conf = '~/.vim/conf/YouCompleteMe/ycm_extra_conf.py'
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_always_populate_location_list = 1
let g:ycm_enable_diagnostic_signs = 0
nnoremap <silent> <leader>j :YcmCompleter GoToDefinitionElseDeclaration<CR>
" vim-airline settings
set noshowmode
set laststatus=2
" disable showing the trailing whitespace
let g:airline#extensions#whitespace#enabled = 0
" commentary settings
function! s:UnsetCommentaryMappings()
if maparg('\\','n') ==# '<Plug>Commentary'
xunmap \\
nunmap \\
nunmap \\\
nunmap \\u
endif
endfunction
augroup commmentary_settings
autocmd!
" disable the default commneary key mapping
autocmd VimEnter * call s:UnsetCommentaryMappings()
autocmd FileType cpp set commentstring=//%s
augroup END
nmap <leader>/ gccj
vmap <leader>/ gc
" vimux settings
let g:VimuxUseNearestPane = 1
vnoremap <silent> <leader>r :<C-u>call VimuxOpenRunner()<Bar>
\call VimuxSendText(<SID>get_visual_selection()."\n")<CR>
" ctrlp settings
let g:ctrlp_max_files = 0
let g:ctrlp_cmd = 'CtrlPLastMode'
" ultisnips settings
let g:UltiSnipsSnippetDirectories = ["Ultisnips", "snippets"]
let g:UltiSnipsSnippetDir = "~/.vim/snippets/"
let g:UltiSnipsExpandTrigger = "<C-j>"
let g:UltiSnipsJumpForwardTrigger = "<C-j>"
let g:UltiSnipsJumpBackwardTrigger = "<C-k>"
" Experimental
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment