Skip to content

Instantly share code, notes, and snippets.

@collin
Last active August 4, 2017 17:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collin/9d3cb322085a90eb9b47b68c60bae761 to your computer and use it in GitHub Desktop.
Save collin/9d3cb322085a90eb9b47b68c60bae761 to your computer and use it in GitHub Desktop.
Collin's vim setup

I use neovim, which is mostly compatible with all vim plugins and apis.

vim-pathogen loads my plugins

I use a few plugins to give me a better editing/navigation experience.

  • ctrlp.vim fuzzy-search to find files in the project by name
  • nerdtree file tree navigator
  • syntastic syntax highlighting and linting
  • vim-better-whitespace cleans up whitespace as I save files
  • vim-indent-guides displays alternating colors to vizualize indentation

My vim config isn't very wild, just enough things to make me happy, I've included it here for the curious.

Why vim?

There are lots of places you can find people sing the praises of editing text with vim. And vim is great for editing text, but that's not really why I chose vim. My reasons for learning/choosing vim are fairly boring:

  • vim is free
  • vim is on the terminal and starts quickly
  • vim is everywhere (on servers, etc.)
  • vim has staying power

Before finding vim I used Eclipse, RadRails, TextMate, SublimeText, and SublimeText 2. They've all passed peak-popularity or ceased development altogether. In the time since choosing vim I've seen Atom and VSCode pop up. That's a lot of editors in less than 15 years. Vim has been around for along time appears to

  • you have to learn vim in order to use it

You can't use vim without learning how to use it. Other editors have a lot of nice features, but you can use them the same way you'd use notepad. I'm lazy and the restriction helps.

Vim has a reputation for being difficult/confusing, but really vim is not that difficult to understand and use. You can learn enough vim to use vim in an afternoon.

execute pathogen#infect()
" Core Vim
autocmd VimEnter * set ts=2 sw=2 expandtab
syntax on
filetype plugin indent on
set backspace=indent,eol,start
colorscheme default
set nu
set hlsearch
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/node_modules/*,*/bower_components/*
" vim:set ft=vim sw=2 sts=2 et:
" Highlilght column 81
let &colorcolumn=join(range(81,81),",")
" Syntastic Settings
map <c-l> :<C-u>call ToggleErrors()<CR>
function! ToggleErrors()
if empty(filter(tabpagebuflist(), 'getbufvar(v:val, "&buftype") is# "quickfix"'))
" No location/quickfix list shown, open syntastic error location panel
Errors
else
lclose
endif
endfunction
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_javascript_checkers = ['eslint']
let g:syntastic_python_checkers = ['flake8']
" Nerdtree Settings
function! StartUp()
if 0 == argc()
NERDTree
end
endfunction
autocmd VimEnter * call StartUp()
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
" Whitespace
autocmd BufWritePre * StripWhitespace
" Clipboard
set clipboard=unnamed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment