Skip to content

Instantly share code, notes, and snippets.

@rsbowman
Created July 6, 2015 19:01
Show Gist options
  • Save rsbowman/e999b75d34559fe6077c to your computer and use it in GitHub Desktop.
Save rsbowman/e999b75d34559fe6077c to your computer and use it in GitHub Desktop.
Vim config
set nocompatible
set encoding=utf-8
" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-git'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-repeat'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'ervandew/supertab'
Plug 'Valloric/YouCompleteMe'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'bling/vim-airline'
Plug 'altercation/vim-colors-solarized'
" Plug 'nelstrom/vim-markdown-folding'
Plug 'lervag/vimtex'
Plug 'tpope/vim-commentary'
Plug 'kien/ctrlp.vim'
Plug 'FelikZ/ctrlp-py-matcher'
Plug 'd11wtq/ctrlp_bdelete.vim'
Plug 'slim-template/vim-slim'
Plug 'Shougo/unite.vim'
" Plug 'junegunn/fzf', { 'dir': '~/.fzf'}
call plug#end()
set rtp+=~/.fzf
inoremap jk <ESC>
let mapleader = "\<Space>"
" don't fold markdown by default
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_math=1
let g:vim_markdown_frontmatter=1
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
" 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>'
let g:clang_user_options='|| exit 0'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" turn airline on always
set laststatus=2
" set up fonts and colors
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 13
let g:airline_powerline_fonts = 1
set background=dark
colorscheme solarized
call ctrlp_bdelete#init()
if !has('python')
echo 'to use pymatcher you need +python'
else
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
endif
let g:ctrlp_lazy_update = 350
let g:ctrlp_max_files = 0
let g:ctrlp_match_window = 'bottom,order:btt,results=100'
let g:ctrlp_working_path_mode = 0
nnoremap <silent> <leader>b :CtrlPBuffer<CR>
nnoremap <silent> <leader>f :CtrlP<CR>
nnoremap <silent> <leader>m :CtrlPMRUFiles<CR>
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 --hidden -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" apply . to every line in selection
vnoremap . :norm.<CR>
nnoremap <Leader>w :w<CR>
" copy and yank from clipboard
vmap <Leader>y "*y
vmap <Leader>d "*d
nmap <Leader>p "*p
nmap <Leader>P "*P
vmap <Leader>p "*p
vmap <Leader>P "*P
" jump to end of text just pasted
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
filetype plugin indent on
syntax on
" tab handling
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
autocmd BufRead,BufNewFile *.md.erb setlocal filetype=mkd
autocmd BufRead,BufNewFile *.adoc.erb setlocal filetype=asciidoc
autocmd FileType text setlocal textwidth=78
autocmd FileType markdown setlocal wrap
autocmd FileType mkd setlocal wrap
autocmd FileType asciidoc setlocal wrap
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2 sts=2
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 sts=2
autocmd FileType css setlocal shiftwidth=2 tabstop=2 sts=2
autocmd FileType html setlocal shiftwidth=2 tabstop=2 sts=2
autocmd FileType eruby setlocal shiftwidth=2 tabstop=2 sts=2
autocmd FileType slim setlocal shiftwidth=2 tabstop=2 sts=2
" misc settings from http://stevelosh.com/blog/2010/09/coming-home-to-vim/
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set number
set relativenumber
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
" searching/moving, from previous post
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault
set incsearch
set showmatch
set hlsearch
nnoremap <leader><space> :noh<cr>
" handled above w/ ,<space>
" nnoremap <CR> :nohlsearch<CR><CR>
" wrapping:
set textwidth=79
set formatoptions=qrn1t
set colorcolumn=80
" recognize astericks as bullets in markdown for example
" from http://unix.stackexchange.com/questions/31288/avoid-reformatting-bullet-lists-with-formatoptions-a
" set flp+=\\\|&\\*\\s*
" This is from http://vi-improved.org/vimrc.html
set flp=^\\s*\\(\\d\\\|[-*]\\)\\+[\\]:.)}\\t\ ]\\s*
match ErrorMsg '\s\+$'
" rtw - Remove Trailing Whitespace
nnoremap <leader>rtw :%s/\s\+$//e<CR>
" close buffer without messing up windows
map <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
" get rid of arrow keys
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
" fill paragraph
vmap Q gq
nmap Q gqap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment