Created
October 19, 2011 22:58
-
-
Save clifton/1299939 to your computer and use it in GitHub Desktop.
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
filetype on " to prevent non-0 exit codes | |
filetype off | |
call pathogen#runtime_append_all_bundles() | |
filetype plugin indent on | |
set nocompatible | |
set modelines=0 | |
set softtabstop=2 | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set guioptions=em | |
set encoding=utf-8 | |
set scrolloff=2 | |
set nocp | |
set et | |
set nobackup | |
set wrap linebreak nolist | |
set autoindent | |
set smartindent | |
set ai | |
set ruler | |
set relativenumber | |
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 paste " less annoying copy - pastes | |
set dir=~/.vim/tmp | |
set shell=/bin/bash | |
set formatprg=par | |
nmap <silent> <leader>s :set spell!<CR> | |
set spelllang=en_us | |
set autoread | |
syntax enable | |
if has('gui_running') | |
set background=light | |
else | |
set background=dark | |
endif | |
set t_Co=16 | |
let g:solarized_termcolors=16 | |
" let g:solarized_visibility='low' | |
colorscheme solarized | |
set guifont=Menlo:h14 | |
call togglebg#map("<F6>") | |
let mapleader = "," | |
" searching / moving | |
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> % | |
" text wrapping | |
set wrap | |
set textwidth=80 | |
set formatoptions=qrn1 | |
" set colorcolumn=81 | |
" dont use 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> | |
" jump to next visual line | |
" nnoremap j gj | |
" nnoremap k gk | |
" scroll viewport a few lines at a time | |
nnoremap <C-e> 3<C-e> | |
nnoremap <C-y> 3<C-y> | |
" ignore annoying help keys | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
" save on losing focus | |
au FocusLost * :wa | |
" set filetypes | |
au BufRead,BufNewFile *.scss set filetype=scss | |
au BufRead,BufNewFile *.god set filetype=ruby | |
" google scribe | |
au filetype vimwiki setl completefunc=googlescribe#Complete | |
au filetype markdown setl completefunc=googlescribe#Complete | |
au filetype gitcommit setl completefunc=googlescribe#Complete | |
nnoremap <leader>A :Ack ""<left> | |
" re-select pasted text for identation / whatever | |
nnoremap <leader>v V`] | |
" open .vimrc in a split tab for quick editing | |
nnoremap <leader>rv <C-w><C-v><C-l>:e $MYVIMRC<cr> | |
" open new split tab | |
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 | |
set matchpairs+=<:> | |
" convenience | |
nnoremap <leader><leader> <c-^> " return to last file | |
nnoremap ; : | |
" system clipboard | |
map <leader>p "*p | |
map <leader>y "*y | |
" open new scratch window | |
nmap <leader><tab> :Scratch<cr> | |
" F5 to remove trailing whitespace | |
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> | |
nnoremap <leader>rl :source $MYVIMRC<cr> | |
" Shortcut to rapidly toggle `set list` | |
nmap <leader>l :set list!<cr> | |
" Use the same symbols as TextMate for tabstops and EOLs | |
set listchars=tab:▸\ ,eol:¬ | |
" Set tabstop, softtabstop and shiftwidth to the same value | |
command! -nargs=* Stab call Stab() | |
function! Stab() | |
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') | |
if l:tabstop > 0 | |
let &l:sts = l:tabstop | |
let &l:ts = l:tabstop | |
let &l:sw = l:tabstop | |
endif | |
endfunction | |
" | |
" destroy all software screencasts | |
" | |
" Open files with <leader>f | |
let g:CommandTCancelMap=['<ESC>','<C-c>'] | |
map <leader>f :CommandTFlush<cr>\|:CommandT<cr> | |
" Open files, limited to the directory of the current file, with <leader>gf | |
" This requires the %% mapping found below. | |
map <leader>gf :CommandTFlush<cr>\|:CommandT %%<cr> | |
let g:CommandTMatchWindowAtTop = 0 | |
let g:CommandTMaxHeight = 12 | |
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr> | |
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr> | |
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr> | |
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr> | |
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr> | |
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr> | |
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr> | |
map <leader>gr :topleft :split config/routes.rb<cr> | |
map <leader>gg :topleft 100 :split Gemfile<cr> | |
function! ShowRoutes() | |
" Requires 'scratch' plugin | |
:topleft 100 :split __Routes__ | |
" Make sure Vim doesn't write __Routes__ as a file | |
:set buftype=nofile | |
" Delete everything | |
:normal 1GdG | |
" Put routes output in buffer | |
:0r! rake -s routes | |
" Size window to number of lines (1 plus rake output length) | |
:exec ":normal " . line("$") . _ " | |
" Move cursor to bottom | |
:normal 1GG | |
" Delete empty trailing line | |
:normal dd | |
endfunction | |
map <leader>gR :call ShowRoutes()<cr> | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>e :edit %% | |
" map <leader>v :view %% | |
set winwidth=84 | |
" 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=5 | |
set winminheight=5 | |
set winheight=999 | |
function! RunTests(filename) | |
" Write the file and run tests for the given filename | |
:w | |
:silent !echo;echo;echo;echo;echo | |
exec ":!script/test " . a:filename | |
endfunction | |
function! SetTestFile() | |
" Set the spec file that tests will be run for. | |
let t:grb_test_file=@% | |
endfunction | |
function! RunTestFile(...) | |
if a:0 | |
let command_suffix = a:1 | |
else | |
let command_suffix = "" | |
endif | |
" Run the tests for the previously-marked file. | |
let in_spec_file = match(expand("%"), '_spec.rb$') != -1 | |
if in_spec_file | |
call SetTestFile() | |
elseif !exists("t:grb_test_file") | |
return | |
end | |
call RunTests(t:grb_test_file . command_suffix) | |
endfunction | |
function! RunNearestTest() | |
let spec_line_number = line('.') | |
call RunTestFile(":" . spec_line_number) | |
endfunction | |
" Run this file | |
map <leader>t :call RunTestFile()<cr> | |
" Run only the example under the cursor | |
map <leader>T :call RunNearestTest()<cr> | |
" Run all test files | |
map <leader>a :call RunTests('spec')<cr> | |
" Ins mode stat line color | |
" TODO: find good colors for this | |
" au InsertEnter * hi StatusLine ctermfg=196 guifg=#D53873 | |
" au InsertLeave * hi StatusLine ctermfg=130 guifg=#CD5907 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment