As a full stack software developer, architect, database administrator, and systems administrator I wear many hats at the office. I often find myself going back and forth between many different servers and environments. One minute I’m troubleshooting a production issue in Postgres, the next I’m wiring up an NPM and webpack environment for a new project. And when I’m finally left alone I will be in my wheelhouse writing code in one of several languages like Go, PHP, JavaScript, HTML, etc. To maximize effeciency I’ve dialed in what I consider an effecient ecosystem of VIM, tmux and iTerm2 tools. Today I’d like to share some of my favorite configurations and plugins.
Buffer and File Mangement
This is the most important part of my setup. My workflow is based around tmux for screen and server management, vim-airline for displaying open files and open buffers as “tabs”, buffergator for viewing open buffers not in view, and git-gutter for showing changed lines. As you can see I typically keep an open window to my left for git commands and database console. When doing front end I keep my npm or webpack watcher active.
Code Editing
For actual code editing I rely on YouCompleteme with exuberant ctags for autocomplete, autopairs for closing braces, UltiSnips for adding snippets like a Symfony2 class or action, and SuperTab to allow me to use the tab key for autocomplete or snippets depending which has precedence.
My .vimrc
Here is a gist of my .vimrc file. Leave a comment if you have a specific question and I’ll try my best to answer. The documenation of my vim plugins is pretty decent and I recommend trying things out first to see if it fits your worflow.
set nocompatible | |
filetype off | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" Plugins loaded by vundle | |
" :PluginInstall | |
Plugin 'gmarik/Vundle.vim' | |
Plugin 'jiangmiao/auto-pairs' | |
Plugin 'majutsushi/tagbar' | |
Plugin 'xolox/vim-lua-ftplugin' | |
Plugin 'xolox/vim-misc' | |
Plugin 'evidens/vim-twig' | |
Plugin 'chriskempson/base16-vim' | |
Plugin 'fatih/vim-go' | |
Plugin 'hdima/python-syntax' | |
Plugin 'bling/vim-airline' | |
Plugin 'edkolev/tmuxline.vim' | |
Plugin 'airblade/vim-gitgutter' | |
Plugin 'justinmk/vim-sneak' | |
Plugin 'mxw/vim-jsx' | |
Plugin 'pangloss/vim-javascript' | |
Plugin 'ervandew/supertab' | |
Plugin 'ctrlpvim/ctrlp.vim' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'jeetsukumaran/vim-buffergator' | |
Plugin 'jelera/vim-javascript-syntax' | |
" Auto-compolete - must be compiled | |
" from within ~/.vim/bundle/YouCompleteMe | |
Plugin 'Valloric/YouCompleteMe' | |
" Snips | |
Plugin 'SirVer/ultisnips' | |
Plugin 'honza/vim-snippets' | |
call vundle#end() " required | |
filetype plugin indent on " filetype detection and settings | |
syntax on " syntax highlighting | |
set backspace=indent,eol,start " let the backspace key work normally | |
set hidden " hide unsaved buffers | |
set incsearch " incremental search rules | |
set laststatus=2 " not strictly necessary but good for consistency | |
set ruler " shows line number in the status line | |
set switchbuf=useopen,usetab " better behavior for the quickfix window and :sb | |
set tags=./tags;/,tags;/ " search tags files efficiently | |
set wildmenu " better command line completion, shows a list of matches | |
set nonu " toggle line numbers | |
set tabstop=4 " tabs to 4 | |
set shiftwidth=4 " amount of spaces when multi-line tabbing with >> | |
set expandtab " hitting tab key will produce tabstop amount of spaces | |
set laststatus=2 " For Status line even with no split | |
set clipboard=unnamed " Make it so copy/paste to system works from vim | |
let mapleader="," " set leader to comma | |
"Unite.vim settings | |
"call unite#custom#source('file_rec/async', 'ignore_pattern', 'node_modules/\|bower_components/\|app/cache/\|app/logs/') | |
"nnoremap <C-p> :Unite file_rec/async<cr> | |
"nnoremap <space>/ :Unite grep:.<cr> | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/cache/*,*/logs/*,*/web/* | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
let g:ctrlp_working_path_mode = 'r' | |
" Syntastic | |
"set statusline+=%#warningmsg# | |
"set statusline+=%{SyntasticStatuslineFlag()} | |
"set statusline+=%* | |
"let g:syntastic_always_populate_loc_list = 1 | |
"let g:syntastic_auto_loc_list = 1 | |
"let g:syntastic_check_on_open = 1 | |
"let g:syntastic_check_on_wq = 0 | |
"let g:syntastic_quiet_messages = { "type": "style" } | |
" 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>" | |
" vim-sneak to act like easymotion | |
nmap s <Plug>Sneak_s | |
let g:sneak#streak = 1 | |
"let g:jsx_ext_required = 0 " Allow JSX in normal JS files" | |
let g:javascript_enable_domhtmlcss = 1 | |
" vim-go settings | |
let g:go_highlight_functions = 1 | |
let g:go_highlight_methods = 1 | |
let g:go_highlight_structs = 1 | |
let g:go_highlight_operators = 1 | |
let g:go_highlight_build_constraints = 1 | |
" python syntax highlighting | |
let python_highlight_all = 1 | |
" UI customizations | |
set t_Co=256 | |
let base16colorspace=256 | |
let g:airline_theme = "sol" | |
let g:airline_powerline_fonts = 1 | |
let g:airline#extensions#tabline#enabled = 1 | |
" Navigation shortcuts | |
map <C-t> :TagbarToggle<CR> " toggle tag bar | |
map <C-l> :bnext<CR> " switch to next buffer | |
map <C-h> :bprevious<CR> " switch to previous buffer |