Created
January 28, 2013 00:26
-
-
Save VinSpee/4651655 to your computer and use it in GitHub Desktop.
This file contains 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
" .vimrc File | |
" Maintained by: Vince Speelman | |
" v@vinspee.me | |
" | |
"Forget compatibility with Vi. Who cares. | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
" let Vundle manage Vundle | |
" required! | |
Bundle 'gmarik/vundle' | |
" My Bundles here: | |
" | |
" original repos on github | |
Bundle 'tpope/vim-fugitive' | |
Bundle 'altercation/vim-colors-solarized' | |
Bundle 'tpope/vim-markdown' | |
Bundle 'tpope/vim-haml' | |
Bundle 'kien/ctrlp.vim' | |
Bundle 'othree/html5.vim' | |
Bundle 'itspriddle/vim-jquery' | |
Bundle 'mattn/webapi-vim.git' | |
Bundle 'mattn/gist-vim' | |
Bundle 'edsono/vim-matchit' | |
Bundle 'tpope/vim-surround' | |
Bundle 'scrooloose/syntastic' | |
Bundle 'lukerandall/align-vim' | |
Bundle 'mileszs/ack.vim' | |
Bundle 'groenewege/vim-less' | |
Bundle 'tsaleh/vim-supertab' | |
Bundle 'kchmck/vim-coffee-script' | |
Bundle 'sjl/gundo.vim' | |
Bundle 'scrooloose/nerdcommenter' | |
Bundle 'Raimondi/delimitMate' | |
Bundle 'docunext/closetag.vim' | |
Bundle 'vim-scripts/DirDo.vim' | |
Bundle 'zefei/buftabs' | |
Bundle 'vim-scripts/DrawIt' | |
Bundle 'jelera/vim-javascript-syntax' | |
Bundle 'mattn/zencoding-vim' | |
Bundle 'MarcWeber/vim-addon-mw-utils' | |
Bundle 'honza/snipmate-snippets' | |
Bundle 'garbas/vim-snipmate' | |
Bundle 'tpope/vim-liquid' | |
"Optimize for terminals | |
set ttyfast | |
"Enable filetypes | |
filetype plugin indent on | |
syntax on | |
"make pasteboard work with tmux / osx | |
set clipboard=unnamed | |
"move tmp files to a specific location | |
set dir=~/tmp | |
set backup | |
set backupdir=~/tmp | |
"Skip Intro | |
set shortmess=atI | |
"Treat tpl's like html | |
au BufNewFile,BufRead *.tpl setfiletype html | |
"Write the old file out when switching between files. | |
set autowrite | |
"Display current cursor position in lower right corner. | |
set ruler | |
"Hilight current line | |
set cursorline | |
"Want a different map leader than \ | |
let mapleader = "," | |
"Ever notice a slight lag after typing the leader key + command? This lowers | |
"the timeout. | |
set timeoutlen=500 | |
"Switch between buffers without saving | |
set hidden | |
" session settings | |
set sessionoptions=resize,winpos,winsize,buffers,tabpages,folds,curdir,help | |
" Tabs Rock. | |
set tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab | |
nnoremap <leader>T :set tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab<cr> | |
" But some people insist on using spaces. They're not smart. | |
nnoremap <leader>S :set tabstop=4 shiftwidth=4 softtabstop=4 expandtab<cr> | |
"Set the color scheme. Change this to your preference. | |
syntax enable | |
set background=light | |
colorscheme solarized | |
"Set font type and size. Depends on the resolution. Larger screens, prefer h20 | |
set guifont="Source Code Pro":h15 | |
"Show command in bottom right portion of the screen | |
set showcmd | |
"Show lines numbers | |
set number | |
"Indent stuff | |
set smartindent | |
set autoindent | |
"Paste mode indent toggle | |
nnoremap <F2> :set invpaste paste?<CR> | |
set pastetoggle=<F2> | |
set showmode | |
"Allow deletion of tabs | |
set backspace=indent,eol,start | |
"Always show the status line | |
set laststatus=2 | |
"Prefer a slightly higher line height | |
set linespace=4 | |
"Better line wrapping | |
set wrap | |
set linebreak | |
set breakat=85 | |
set formatoptions=qrn1 | |
set colorcolumn=85 | |
" Fix Searching | |
nnoremap / /\v | |
vnoremap / /\v | |
set ignorecase | |
set smartcase | |
set gdefault | |
set incsearch | |
set showmatch | |
set hlsearch | |
nnoremap <leader><space> :noh<cr> | |
nnoremap <tab> % | |
vnoremap <tab> % | |
"Open a Quickfix window for the last search. | |
nnoremap <silent> ,/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR> | |
"Show hidden chars like textmate | |
set list | |
set listchars=tab:▷⋅,trail:⋅,nbsp:⋅ | |
" Map ; to : | |
nnoremap ; : | |
"Hide MacVim toolbar by default | |
set go-=T | |
"Enable code folding | |
set foldmethod=indent | |
set foldnestmax=3 | |
set foldlevel=1 | |
set nofoldenable | |
"Shortcut to fold tags with leader (usually \) + ft | |
nnoremap <leader>ft Vatzf | |
"Hide mouse when typing | |
set mousehide | |
set mouse=a | |
"Split windows below the current window. | |
set splitbelow | |
"Prettify Vertical Splitter | |
set fillchars=vert:│ " that's a vertical box-drawing character | |
"Set up an HTML5 template for all new .html files | |
"autocmd BufNewFile * silent! 0r $VIMHOME/templates/%:e.tpl | |
"Shortcut for editing vimrc file in a new tab | |
nmap <leader>ev :tabedit $MYVIMRC<cr> | |
"Change zen coding plugin expansion key to shift + e | |
let g:user_zen_expandabbr_key = '<C-e>' | |
"Faster shortcut for commenting. Requires T-Comment plugin | |
map <leader>c <c-_><c-_> | |
"Select function | |
nnoremap <leader>B ?function<cr>jva{Vo{ | |
" More useful command-line completion | |
set wildmenu | |
if v:version >= 703 | |
"undo settings | |
set undodir=~/.vim/undofiles | |
set undofile | |
set colorcolumn=+1 "mark the ideal max text width | |
endif | |
"Map escape key to jj -- much faster | |
imap jj <esc> | |
"Delete all buffers (via Derek Wyatt) | |
nmap <silent> ,da :exec "1," . bufnr('$') . "bd"<cr> | |
"Bubble single lines (kicks butt) | |
"http://vimcasts.org/episodes/bubbling-text/ | |
nmap <C-Up> ddkP | |
nmap <C-Down> ddp | |
"Bubble multiple lines | |
vmap <C-Up> xkP`[V`] | |
vmap <C-Down> xp`[V`] | |
" Source the vimrc file after saving it. This way, you don't have to reload Vim to see the changes. | |
if has("autocmd") | |
augroup myvimrchooks | |
au! | |
autocmd bufwritepost .vimrc source ~/.vimrc | |
augroup END | |
endif | |
" Closes the current buffer | |
nnoremap <silent> <Leader>q :bd<CR> | |
" Save with ,` | |
nnoremap <Leader>w :w<CR> | |
" Ctrl-h,j,k,l for split navigation | |
map <C-H> <C-W>h | |
map <C-L> <C-W>l | |
map <C-J> <C-W>j | |
map <C-K> <C-W>k | |
" Use + and - to size splits | |
nnoremap <silent> + :res +10<CR> | |
nnoremap <silent> - :res -10<CR> | |
" resize horzontal split window | |
nmap <leader><Left> <C-W>-<C-W>- | |
nmap <leader><Right> <C-W>+<C-W>+ | |
" resize vertical split window | |
nmap <C-Up> <C-W>><C-W>> | |
nmap <C-Down> <C-W><<C-W>< | |
" Autocomplete | |
set ofu=syntaxcomplete#Complete | |
set completeopt=longest,menuone | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
inoremap <expr> <C-n> pumvisible() ? '<C-n>' : | |
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>' | |
inoremap <expr> <M-,> pumvisible() ? '<C-n>' : | |
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>' | |
let g:SuperTabDefaultCompletionType = "context" | |
" CtrlP | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_working_path_mode = 2 | |
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$|\.DS_Store$\' | |
" Remove toolbars | |
set guioptions=egt | |
set guioptions-=Tmr | |
" Automatically Reload Externally Modified CSS Files | |
augroup vimrcAu | |
au! | |
au BufEnter,BufNew *.css setlocal autoread | |
augroup END | |
" ----------------------- " | |
" Custom Leader Functions " | |
" ----------------------- " | |
" Show tagbar | |
let Tlist_WinWidth='auto' | |
let Tlist_javascript_Hide_Extras=['type'] | |
nnoremap <leader>tl :TlistToggle<cr> | |
" Strip Trailing Whitespace | |
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> | |
"Ack | |
nnoremap <leader>a :Ack | |
"Fold Tag | |
nnoremap <leader>ft Vatzf | |
"Hardwrap | |
nnoremap <leader>w gqip | |
"Select Pasted Text | |
nnoremap <leader>v V`] | |
" Super Retab | |
nmap <leader>rt :%s/\s\+$//<cr>:let @/=''<CR>:%retab!<CR> | |
"Navigate Buffers w/ leader | |
noremap <leader>z :bprev!<CR> | |
noremap <leader>x :bnext!<CR> | |
noremap <leader>d :confirm bd<CR> | |
"Fun | |
"tiny success: http://bit.ly/RhpepU | |
"osx specific, mpg123 or the like for linux | |
nmap <leader>hh :silent ! afplay $HOME/.vim/audio/succ_horns01.mp3 1>&-2>&-&<CR><C-l> | |
"here is a more exotic version of my original Kwbd script | |
"delete the buffer; keep windows; create a scratch buffer if no buffers left | |
function s:Kwbd(kwbdStage) | |
if(a:kwbdStage == 1) | |
if(!buflisted(winbufnr(0))) | |
bd! | |
return | |
endif | |
let s:kwbdBufNum = bufnr("%") | |
let s:kwbdWinNum = winnr() | |
windo call s:Kwbd(2) | |
execute s:kwbdWinNum . 'wincmd w' | |
let s:buflistedLeft = 0 | |
let s:bufFinalJump = 0 | |
let l:nBufs = bufnr("$") | |
let l:i = 1 | |
while(l:i <= l:nBufs) | |
if(l:i != s:kwbdBufNum) | |
if(buflisted(l:i)) | |
let s:buflistedLeft = s:buflistedLeft + 1 | |
else | |
if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump) | |
let s:bufFinalJump = l:i | |
endif | |
endif | |
endif | |
let l:i = l:i + 1 | |
endwhile | |
if(!s:buflistedLeft) | |
if(s:bufFinalJump) | |
windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif | |
else | |
enew | |
let l:newBuf = bufnr("%") | |
windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif | |
endif | |
execute s:kwbdWinNum . 'wincmd w' | |
endif | |
if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%")) | |
execute "bd! " . s:kwbdBufNum | |
endif | |
if(!s:buflistedLeft) | |
set buflisted | |
set bufhidden=delete | |
set buftype= | |
setlocal noswapfile | |
endif | |
else | |
if(bufnr("%") == s:kwbdBufNum) | |
let prevbufvar = bufnr("#") | |
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum) | |
b # | |
else | |
bn | |
endif | |
endif | |
endif | |
endfunction | |
command Kwbd call s:Kwbd(1) | |
nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR> | |
" Create a mapping (e.g. in your .vimrc) like this: | |
nmap <leader>bq <Plug>Kwbd | |
nnoremap <Leader>H :call<SID>LongLineHLToggle()<cr> | |
hi OverLength ctermbg=none cterm=none | |
match OverLength /\%>80v/ | |
fun! s:LongLineHLToggle() | |
if !exists('w:longlinehl') | |
let w:longlinehl = matchadd('ErrorMsg', '.\%>80v', 0) | |
echo "Long lines highlighted" | |
else | |
call matchdelete(w:longlinehl) | |
unl w:longlinehl | |
echo "Long lines unhighlighted" | |
endif | |
endfunction | |
" Itchy Scratch buffers | |
let g:itchy_always_split=0 | |
let g:itchy_split_direction=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment