Skip to content

Instantly share code, notes, and snippets.

@heisters
Created March 31, 2011 16:52
Show Gist options
  • Save heisters/896748 to your computer and use it in GitHub Desktop.
Save heisters/896748 to your computer and use it in GitHub Desktop.
my vimrc
set nocompatible " We're running Vim, not Vi!
set hidden
set title
set list
set listchars=tab:»·,trail:·
"set ai sw=2 sts=2 et
set t_Co=256 " lots of colors
set incsearch
syntax on
set scrolloff=2 " make it scroll before I hit the edge
set modelines=5 " the modeline can be in any of the first 5 lines
let mapleader=","
set autoindent
set smartindent
" nice status line:
set laststatus=2
set statusline=%F%m%r%h%w\ %Y\ %v,%l/%L\ (%p%%)
" folding defined by the syntax file
"set foldmethod=syntax
noremap <silent> Z :set foldmethod=syntax<CR>
" don't make it look like there are line breaks where there aren't:
set nowrap
" Enable filetype-specific indenting and plugins
filetype plugin indent on
" Load matchit (% to bounce from do to end, etc.)
runtime! macros/matchit.vim
"let g:zenburn_high_Contrast=1
"colorscheme zenburn
"colorscheme bog
colorscheme ir_black
" Running tests
function! RailsScriptIfExists(name)
" Bundle exec
if isdirectory(".bundle") || (exists("b:rails_root") && isdirectory(b:rails_root . "/.bundle"))
return "bundle exec " . a:name
" Script directory
elseif exists("b:rails_root") && filereadable(b:rails_root . "/script/" . a:name)
return b:rails_root . "/script/" . a:name
" System Binary
else
return a:name
end
endfunction
function! RunSpec(args)
let spec = RailsScriptIfExists("spec")
let cmd = spec . " " . a:args . " -fn -c " . @%
" add support for Rspec 2
let spec2 = RailsScriptIfExists("rspec")
let cmd2 = spec2 . " " . a:args . " -fn -c " . @%
"execute ":! echo " . cmd . " && " . cmd . " || (" . "echo " . cmd2 . " && " . cmd2 . ")"
execute ":! echo " . cmd2 . " && " . cmd2
endfunction
function! RunCucumber(args)
let cucumber = RailsScriptIfExists("cucumber")
let cmd = cucumber . " " . @% . a:args
execute ":! echo " . cmd . " && " . cmd
endfunction
function! RunTestFile(args)
if @% =~ "\.feature$"
call RunCucumber("" . a:args)
elseif @% =~ "\.rb$"
call RunSpec("" . a:args)
end
endfunction
function! RunTest(args)
if @% =~ "\.feature$"
call RunCucumber(":" . line('.') . a:args)
elseif @% =~ "\.rb$"
call RunSpec("-l " . line('.') . a:args)
end
endfunction
map <Leader>V :call RunTestFile("")
map <Leader>v :call RunTest("")
" CTags
let Tlist_Ctags_Cmd = "/usr/bin/env ctags"
let Tlist_WinWidth = 50
function! BuildCtags(path)
let cmd = a:path . " -R --exclude='\.git' --exclude='public' --exclude='*.sql' ."
execute ":! echo " . cmd . " && " . cmd
endfunction
map <Leader>c :TlistToggle<cr>
map <Leader>C :call BuildCtags(Tlist_Ctags_Cmd)<cr>
" Enable/disable automatic jslint
function! DisableJSLint()
autocmd! BufWritePost,FileWritePost *.js
endfunction
function! EnableJSLint()
autocmd BufWritePost,FileWritePost *.js call JavascriptLint()
endfunction
command! -nargs=0 Nojsl :call DisableJSLint()
command! -nargs=0 Jsl :call EnableJSLint()
" Paste-mode toggle shortcut
command! -nargs=0 Pt :set invpaste
" Easier buffer switching
noremap <silent> <C-l> :bn<CR>
noremap <silent> <C-h> :bp<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment