Skip to content

Instantly share code, notes, and snippets.

@pertrai1
Last active December 6, 2016 09:24
Show Gist options
  • Select an option

  • Save pertrai1/5cdbdcfe6b9d6dac655b7206033ddf93 to your computer and use it in GitHub Desktop.

Select an option

Save pertrai1/5cdbdcfe6b9d6dac655b7206033ddf93 to your computer and use it in GitHub Desktop.
Updated VIMRC
" https://thoughtbot.com/upcase/the-art-of-vim
" http://learnvimscriptthehardway.stevelosh.com/
set nocompatible
set encoding=utf-8
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'
Plugin 'bling/vim-bufferline'
Plugin 'easymotion/vim-easymotion'
Plugin 'tpope/vim-fugitive'
Plugin 'rking/ag.vim'
Plugin 'xolox/vim-easytags'
Plugin 'xolox/vim-misc'
Plugin 'rizzatti/dash.vim'
Plugin 'tomtom/tcomment_vim'
Plugin 'tpope/vim-surround'
Plugin 'sickill/vim-monokai'
call vundle#end()
colorscheme Monokai
filetype plugin indent on
syntax enable
let mapleader=","
set number
set showmode
set showcmd
set ruler
set laststatus=2
set backspace=indent,eol,start
set hidden
set autoindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set noexpandtab
set tags=./tags;/
set hlsearch
set incsearch
nnoremap <silent><BS> :nohlsearch<CR>
set splitbelow
set splitright
set noswapfile
set nobackup
set nowb
set list lcs=trail:·,tab:»·
nnoremap ; :
set wildmenu
set wildmode=list:longest
set wildignore+=*vim/backups*
set wildignore+=*DS_Store*
set wildignore+=node_modules/**
set wildignore+=dist/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
set foldmethod=marker
set foldnestmax=3
set nofoldenable
"Visual mappings
vnoremap < <gv
vnoremap > >gv
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
nnoremap <C-p> :CtrlP<CR>
imap <C-p> <esc>:CtrlP<CR>
" Open goto symbol on current buffer
nmap <C-r> :CtrlPTag<CR>
imap <C-r> <esc>:CtrlpTag<CR>
" Open goto symbol on all buffers
nmap <C-R> :CtrlPBufTagAll<CR>
imap <C-R> <esc>:CtrlPBufTagAll<CR>
" Open goto file
nmap <C-t> :CtrlP<CR>
imap <C-t> <esc>:CtrlP<CR>
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_by_filename = 1
let g:ctrlp_switch_buffer = 'et'
let g:ctrlp_match_window = 'bottom,order:btt'
nnoremap <S-n> :NERDTreeToggle<CR>
nnoremap <S-f> :NERDTreeFind<CR>
let g:NERDTreeChDirMode=2
let g:NERDTreeShowBookmarks=1
let g:NERDTreeShowHidden=1
let g:EasyMotion_keys='asdfjkoweriop'
nmap ,<ESC> ,,w
nmap ,<S-ESC> ,,b
nnoremap <S-b> :bp<CR>
nnoremap <S-n> :bn<CR>
nnoremap <S-l> :ls<CR>
" https://robots.thoughtbot.com/faster-grepping-in-vim
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files.
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP does not need cache
let g:ctrlp_use_caching = 0
endif
"bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
nnoremap <Leader>g :silent execute "grep! -R " . shellescape(expand("<cWORD>")) . " . "<CR>:copen<CR>
nnoremap \ :Ag<SPACE>
augroup refreshVimrc
autocmd!
autocmd BufWritePost .vimrc source $MYVIMRC
autocmd BufWritePre *.js,*.css,*.html,*.vim silent %s/\s\+$//e
augroup END
" http://vim.wikia.com/wiki/Use_folds_in_your_program
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Idea from : http://www.charlietanksley.net/blog/blog/2011/10/18/vim-navigation-with-lustyexplorer-and-lustyjuggler/
" mnemonic 'jump to [something]'
map ,js :CtrlP Content/js<CR>
map ,jl :CtrlP Content/less<CR>
map ,jp :CtrlP Views/partials<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment