Skip to content

Instantly share code, notes, and snippets.

@rbnvrw
Last active March 12, 2016 20:32
Show Gist options
  • Save rbnvrw/c88be17567dc7223a0df to your computer and use it in GitHub Desktop.
Save rbnvrw/c88be17567dc7223a0df to your computer and use it in GitHub Desktop.
Quick vim tips
" move vertically by visual line
nnoremap j gj
nnoremap k gk
" highlight just the 81st column of wide lines... (Damian Conway)
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)
" Enable code folding
set foldenable
" Use space to toggle folds and create folds
nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap <Space> zf
" Set foldmethod to indent and allow manual
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
set foldlevelstart=10 " Open most folds by default
set foldnestmax=10 " 10 nested folds max
" 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 ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
" define :Ag
if !exists(":Ag")
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
endif
" bind K to grep word under cursor
nnoremap K :silent! grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
nnoremap \ :Ag<SPACE>
" Syntastic {{{
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_id_checkers = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_python_python_exec = '/usr/bin/python3'
let g:syntastic_python_checkers = ['python', 'pylint']
let g:syntastic_enable_signs = 1
let g:syntastic_error_symbol = '❌'
let g:syntastic_style_error_symbol = '⁉️'
let g:syntastic_warning_symbol = '⚠️'
let g:syntastic_style_warning_symbol = 'ℹ'
highlight link SyntasticErrorSign SignColumn
highlight link SyntasticWarningSign SignColumn
highlight link SyntasticStyleErrorSign SignColumn
highlight link SyntasticStyleWarningSign SignColumn
" }}}
" Clipboard shortcuts {{{
nnoremap <C-y> "+y
vnoremap <C-y> "+y
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment