Skip to content

Instantly share code, notes, and snippets.

Last active November 14, 2017 19:44
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
minimal vimrc file
set nocompatible " be iMproved, required
set background=dark
syntax enable
filetype on " without this vim emits a zero exit status, later, because of :ft off
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'mattn/emmet-vim'
Plugin 'reedes/vim-colors-pencil'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'pangloss/vim-javascript'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'rking/ag.vim'
Plugin 'vim-scripts/YankRing.vim'
Plugin 'tpope/vim-surround'
Plugin 'Yggdroot/indentLine'
Plugin 'marijnh/tern_for_vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'maksimr/vim-jsbeautify'
Plugin 'mileszs/ack.vim'
call vundle#end()
filetype plugin indent on
let mapleader = ','
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
set term=xterm-256color
set number
set tabstop=2
set expandtab
set shiftwidth=2
set autoindent
set autoread " reload files when changed on disk, i.e. via `git checkout`
set backspace=2 " Fix broken backspace in some setups
set backupcopy=yes " see :help crontab
set clipboard=unnamed " yank and paste with the system clipboard
set directory-=. " don't store swapfiles in the current directory
set encoding=utf-8
set expandtab " expand tabs to spaces
set ignorecase " case-insensitive search
set incsearch " search as you type
set smartindent
set laststatus=2
set list " show trailing whitespace
set listchars=tab:▸\ ,trail:▫
set number " show line numbers
set ruler " show where you are
set scrolloff=3 " show context above/below cursorline
set showcmd
set smartcase " case-sensitive search if any caps
set wildmenu " show a navigable menu for tab completion
set wildmode=longest,list,full
set completeopt-=preview
" Enable basic mouse behavior such as resizing buffers.
set mouse=a
if exists('$TMUX') " Support resizing in tmux
set ttymouse=xterm2
" keyboard shortcuts
inoremap jj <ESC>
nnoremap ; :
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" Navigate between splits
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>
noremap <leader>l :Align
nnoremap <leader>a :Ag<space>
nnoremap <leader>b :CtrlPBuffer<CR>
nnoremap <leader>t :CtrlP<CR>
nnoremap <leader>T :CtrlPClearCache<CR>:CtrlP<CR>
nnoremap <leader>] :TagbarToggle<CR>
nnoremap <leader><space> :call whitespace#strip_trailing()<CR>
nnoremap <leader>g :GitGutterToggle<CR>
noremap <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" in case you forgot to sudo
cnoremap w!! %!sudo tee > /dev/null %
" plugin settings
let g:ctrlp_match_window = 'order:ttb,max:20'
let g:gitgutter_enabled = 0
" Use The Silver Searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
set splitbelow
set splitright
let g:netrw_liststyle=3
let g:netrw_banner=0
" Ignore things
set wildignore+=*.swp,*.bak,*.pyc,*.class,*/dist
" No pooping backup files
set nobackup
set noswapfile
" highlight search
set hlsearch
nmap <leader>w :nohlsearch<CR>
nmap <leader>hl :let @/ = ""<CR>
" grep
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
" md is markdown
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.md set spell
" Tell vim to use javascript syntax for JSON files
autocmd BufNewFile,BufRead *.json set ft=javascript
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" strip whitespace
autocmd BufWritePre * %s/\s\+$//e
" Copy paste
set pastetoggle=<F2>
nnoremap <leader>y :YRShow<CR>
" Expansion to active file directory
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
noremap <tab> %
" Save on focus out of file
au FocusLost * :wa
" Theme
colors pencil
" Airline
let g:airline_powerline_fonts = 1
let g:airline_theme='light'
let g:Powerline_symbols = 'fancy'
" indent line
let g:indentLine_enabled = 1
let g:indentLine_char = '│'
let g:indentLine_color_term = 239
let g:indentLine_color_gui = '#9474b2'
let g:indentLine_color_tty_light = 2 " (default: 4)
let g:indentLine_color_dark = 1 " (default: 2)
" lint
" let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_javascript_checkers = ['standard']
" autocmd bufwritepost *.js silent !standard --fix %
" set autoread
" Disambiguate ,a & ,t from the Align plugin, making them fast again.
" This section is here to prevent AlignMaps from adding a bunch of mappings
" that interfere with the very-common ,a and ,t mappings. This will get run
" at every startup to remove the AlignMaps for the *next* vim startup.
" If you do want the AlignMaps mappings, remove this section, remove
" ~/.vim/bundle/Align, and re-run rake in maximum-awesome.
function! s:RemoveConflictingAlignMaps()
if exists("g:loaded_AlignMapsPlugin")
command! -nargs=0 RemoveConflictingAlignMaps call s:RemoveConflictingAlignMaps()
silent! autocmd VimEnter * RemoveConflictingAlignMaps
map <c-f> :call JsBeautify()<cr>
" or
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
" for html
autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
" for css or scss
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
" C completion
let g:clang_library_path='/Applications/'
" tern
nnoremap <Leader>tD :TernDoc<CR>
let g:tern_map_keys=1
let g:tern_show_argument_hints='on_hold'
set cursorline
hi CursorLine guibg=Grey40
" Fix Cursor in TMUX
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" UtiliSnips YCM SuperTab
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" Don't copy the contents of an overwritten selection.
vnoremap p "_dP
Copy link

kristoferjoseph commented Jul 12, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment