Created
January 8, 2012 12:53
-
-
Save iain/1578280 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
syntax on | |
filetype plugin indent on | |
" Don't redraw during macro execution | |
set lazyredraw | |
" tir_black looks most like ir_black in console | |
colorscheme tir_black | |
" Syntax coloring lines that are too long just slows down the world | |
set synmaxcol=2048 | |
" Normal line numbering | |
set number | |
set nowrap | |
" max width | |
set textwidth=100 | |
" I don't care what language I use, 2 spaces per tab! | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
set autoindent | |
set cindent | |
set smartindent | |
set smarttab | |
" Turn off beep | |
set vb t_vb= | |
" Directly switch between open splitted windows | |
map <C-J> <C-W>j | |
map <C-H> <C-W>h | |
map <C-L> <C-W>l | |
map <C-K> <C-W>k | |
" Map ,e and ,v to open files in the same directory as the current file | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
map <leader>e :edit %% | |
map <leader>v :view %% | |
map <leader>m :vsplit %% | |
map <leader>n :split %% | |
" create equally sized splits | |
set equalalways | |
set splitbelow splitright | |
" Backspace normally | |
set backspace=indent,eol,start | |
" Rename :W to :w | |
command! W :w | |
" Turn off F1 | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
" in insert mode, jj goes to normal mode | |
" if you ever need to type jj for real, type it slowly, like on old school mobile phones | |
inoremap jj <ESC> | |
" Search | |
set smartcase | |
set incsearch | |
set showmatch | |
set hlsearch | |
map <leader>\ :noh<cr> | |
" Turn off arrow keys in normal mode | |
nnoremap <up> <nop> | |
nnoremap <down> <nop> | |
nnoremap <left> <nop> | |
nnoremap <right> <nop> | |
" Turn off arrow keys in insert mode | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> | |
" Turn off arrow keys in visual mode | |
vnoremap <up> <nop> | |
vnoremap <down> <nop> | |
vnoremap <left> <nop> | |
vnoremap <right> <nop> | |
" pressing j or k in a long wrapped will put cursor down/up one visual line | |
nnoremap j gj | |
nnoremap k gk | |
" Keep a few lines above and below current line | |
set scrolloff=4 | |
" Fast window resizing with +/- keys (horizontal); / and * keys (vertical) | |
" only keypad | |
if bufwinnr(1) | |
map <kPlus> 5<C-W>+ | |
map <kMinus> 5<C-W>- | |
map <kDivide> 5<c-w>< | |
map <kMultiply> 5<c-w>> | |
endif | |
" Run current (or last) spec file by calling <leader>t. (see below) | |
" Got this from @garybernhardt and his excellent destroyallsoftware.com screencasts | |
function! RunTests(filename) | |
" Write the file and run tests for the given filename | |
:w | |
:silent !clear | |
:silent exec ":!echo \"\e[0;34m$ rspec -fd " . substitute(a:filename, getcwd() . "/", "", "") . "\e[0m\"" | |
exec ":!time rspec -fd " . 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 | |
map <leader>t :call RunTestFile()<cr> | |
map <leader>T :call RunNearestTest()<cr> | |
map <leader>a :call RunTests('spec')<cr> | |
map <leader>c :w\|:!cucumber<cr> | |
map <leader>C :w\|:!cucumber --profile wip<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment