Created
October 20, 2014 16:08
-
-
Save clifton/fa1341a3d1d1db4f6ed2 to your computer and use it in GitHub Desktop.
vim.rc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
filetype on " to prevent non-0 exit codes | |
filetype off | |
" | |
" PLUGINS | |
" | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/Vundle.vim' | |
Plugin 'tpope/vim-surround' " surround verb for many types | |
Plugin 'tpope/vim-repeat' " repeat complex commands | |
Plugin 'tpope/vim-speeddating' " incr/decr complex types ^A/^X | |
Plugin 'tpope/vim-commentary' " verb-like commenting | |
Plugin 'kana/vim-textobj-user' " define custom text objects | |
Plugin 'nelstrom/vim-textobj-rubyblock' " text objects for ruby (blocks) | |
Plugin 'quanganhdo/grb256' " colorscheme | |
Plugin 'kien/ctrlp.vim' " fuzzy finder | |
Plugin 'dag/vim-fish' " fish syntax | |
Plugin 'scrooloose/syntastic' " syntax checking | |
Plugin 'christoomey/vim-tmux-navigator' " tmux aware splits | |
call vundle#end() | |
filetype plugin indent on | |
set encoding=utf-8 | |
" | |
" DISPLAY | |
" | |
set scrolloff=2 | |
set nocp | |
set et | |
set nobackup | |
set wrap linebreak nolist | |
set autoindent | |
set smartindent | |
set ai | |
set ruler | |
set relativenumber | |
set cursorline | |
set undofile | |
set undodir=~/.vim-tmp | |
set backspace=indent,eol,start | |
set laststatus=2 | |
set showcmd | |
set showmode | |
set hidden | |
set wildmenu | |
set wildmode=list:longest | |
set visualbell | |
set ttyfast | |
set shell=/bin/bash | |
set title | |
set formatprg=par | |
set spelllang=en_us | |
set autoread | |
set lazyredraw | |
syntax enable | |
colorscheme grb256 | |
" | |
" MODELINE | |
" | |
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) | |
" | |
" WINDOW/PANES | |
" | |
set scrolljump=4 | |
set winwidth=86 | |
" We have to have a winheight bigger than we want to set winminheight. But if | |
" we set winheight to be huge before winminheight, the winminheight set will | |
" fail. | |
set winheight=7 | |
set winminheight=7 | |
set winheight=999 | |
if exists('+relativenumber') | |
autocmd WinLeave * | |
\ if &rnu==1 | | |
\ exe "setl norelativenumber" | | |
\ exe "setl nu" | | |
\ endif | |
autocmd BufRead,BufNewFile,BufEnter,WinEnter * | |
\ if &rnu==0 | | |
\ exe "setl rnu" | | |
\ endif | |
endif | |
" | |
" SEARCH | |
" | |
set ignorecase | |
set smartcase | |
set gdefault | |
set incsearch | |
set showmatch | |
set hlsearch | |
set matchpairs+=<:> | |
" | |
" TABS/WRAPPING | |
" | |
set softtabstop=2 | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set wrap | |
set textwidth=80 | |
set formatoptions=qrn1 | |
" This is for setting Makefiles with tabs not spaces | |
autocmd FileType make setlocal noexpandtab | |
" Use the same symbols as TextMate for tabstops and EOLs | |
set listchars=tab:▸\ ,eol:¬ | |
" | |
" MOUSE | |
" | |
set guioptions=em | |
set mouse=a | |
" | |
" KEYBOARD | |
" | |
set noesckeys " remove delay from ^O ^I | |
let mapleader = "," | |
nnoremap <leader><leader> <c-^> " return to last file | |
nnoremap ; : | |
nmap <silent> <leader>s :set spell!<CR> | |
nnoremap <leader><space> :noh<cr> | |
nnoremap <tab> % | |
vnoremap <tab> % | |
" scroll viewport 3 lines at a time | |
nnoremap <C-e> 3<C-e> | |
nnoremap <C-y> 3<C-y> | |
" F5 removes trailing whitespace | |
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> | |
" vimrc editing | |
nnoremap <leader>rl :source $MYVIMRC<cr> | |
nnoremap <leader>rv <C-w><C-v><C-l>:e $MYVIMRC<cr> | |
" split convenience | |
nnoremap <leader>w <C-w>v | |
nnoremap <leader>W <C-w>s | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" system clipboard | |
map <leader>p "*p | |
map <leader>y "*y | |
" open new scratch window | |
nmap <leader><tab> :Scratch<cr> | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>e :edit %% | |
" | |
" FILETYPES | |
" | |
augroup vimrcEx | |
" Clear all autocmds in the group | |
autocmd! | |
autocmd FileType text setlocal textwidth=78 | |
" Jump to last cursor position unless it's invalid or in an event handler | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
"for ruby, autoindent with two spaces, always expand tabs | |
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et | |
autocmd FileType python set sw=4 sts=4 et | |
autocmd! BufRead,BufNewFile *.sass setfiletype sass | |
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:> | |
autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:> | |
" Don't syntax highlight markdown because it's often wrong | |
autocmd! FileType mkd setlocal syn=off | |
augroup END | |
autocmd FileType fish compiler fish | |
" | |
" HTML | |
" | |
let html_no_rendering=1 | |
" | |
" CTRLP | |
" | |
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/tmp/*,*/node_modules/*,*.gif,*.jpg,*.jpeg,*.png | |
let g:ctrlp_working_path_mode = 0 " dont manage current working directory | |
let g:ctrlp_match_window_reversed = 0 " top to bottom | |
let g:ctrlp_max_height = 12 | |
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp' | |
let g:ctrlp_clear_cache_on_exit = 0 " use F5 with ctrlp open to clear it | |
let g:ctrlp_custom_ignore = { | |
\ 'dir': '\.git$\|\.hg$\|\.svn$|public$\|vendor$', | |
\ 'file': '\.exe$\|\.so$\|\.dll$', | |
\ } | |
" | |
" SYNTASTIC | |
" | |
map <leader>f :CtrlP<cr> | |
map <leader>. :CtrlPMRU<cr> | |
map <leader>gb :CtrlPBuffer<cr> | |
map <leader>gf :CtrlP %%<cr> | |
map <leader>gl :CtrlP lib<cr> | |
map <leader>gj :CtrlP app/assets/javascripts<cr> | |
map <leader>gs :CtrlP app/assets/stylesheets<cr> | |
map <leader>gc :CtrlP app/controllers<cr> | |
map <leader>gd :CtrlP app/modules<cr> | |
map <leader>gm :CtrlP app/models<cr> | |
map <leader>gh :CtrlP app/helpers<cr> | |
map <leader>gv :CtrlP app/views<cr> | |
" | |
" RAILS | |
" | |
map <leader>gr :topleft :split config/routes.rb<cr> | |
map <leader>gg :topleft 100 :split Gemfile<cr> | |
" | |
" OMNICOMPLETE | |
" | |
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | |
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | |
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS | |
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | |
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-n>" | |
endif | |
endfunction | |
" some idiot plugin overwrites <tab> mapping | |
au VimEnter * inoremap <tab> <c-r>=InsertTabWrapper()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment