Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
377 lines (320 sloc) 11 KB
" Use Pathogen:
call pathogen#infect()
" call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" ================
" Ruby stuff
" ================
syntax on " Enable syntax highlighting
filetype plugin indent on " Enable filetype-specific indenting and plugins
set shellcmdflag=-lc " Start as a login shell (which loads bash_profile )
" which spawns my other shell files
augroup myfiletypes
" Clear old autocmds in group
" autoindent with two spaces, always expand tabs
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
autocmd BufNewFile,BufRead *.pill set ft=ruby
autocmd BufNewFile,BufRead *.hamlc set ft=haml
autocmd BufNewFile,BufRead *.json set ft=javascript
autocmd FileType javascript set ai sw=4 ts=4 sts=4 textwidth=79
autocmd FileType coffee set ai sw=2 ts=2 textwidth=79
autocmd BufNewFile,BufRead *.as set ft=javascript
autocmd FileType ruby autocmd BufWritePre <buffer> :%s/\s\+$//e "delete trailing whitespace
" autocmd BufWritePost,FileWritePost *.js call JavascriptLint()
augroup END
" ================
let mapleader = ","
nmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a{ :Tabularize /{<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>b :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
vmap <Leader>bed "td?describe<cr>obed<tab><esc>"tpkdd/end<cr>o<esc>:nohl<cr>
map <Leader>cc :!cucumber --drb %<CR>
map <Leader>co :TComment<CR>
map <Leader>d odebugger<cr>puts 'debugger'<esc>:w<cr>
map <Leader>gac :Gcommit -m -a ""<LEFT>
map <Leader>gc :Gcommit -m ""<LEFT>
map <Leader>gs :Gstatus<CR>
map <Leader>f :sp spec/factories.rb<CR>
map <Leader>fix :cnoremap % %<CR>
map <Leader>fa :sp test/factories.rb<CR>
map <Leader>t :CommandT<CR>
map <Leader>i mmgg=G`m<CR>
map <Leader>l :!ruby -I"test" -I"spec" %<CR>
map <Leader>m :Rmodel
map <Leader>n :set nopaste<cr>
map <Leader>o :call RunCurrentLineInTest()<CR>
map <Leader>p :set paste<CR>"*p:set nopaste<cr>
map <Leader>rd :!bundle exec rspec % --format documentation<CR>
map <Leader>rf :CommandTFlush<CR>
map <Leader>r :NERDTreeFind<CR>
map <Leader>rw :%s/\s\+$//
map <Leader>sc :sp db/schema.rb<cr>
map <Leader>sm :RSmodel
map <Leader>snip :e ~/.vim/snippets/ruby.snippets<CR>
map <Leader>su :RSunittest
map <Leader>sv :RSview
map <Leader>h :call RunCurrentTest()<CR>
map <Leader>y :!rspec --drb %<cr>
map <Leader>u :Runittest<cr>
map <Leader>vc :RVcontroller<cr>
map <Leader>vf :RVfunctional<cr>
map <Leader>vi :tabe ~/.vimrc<CR>
map <Leader>vu :RVunittest<CR>
map <Leader>vm :RVmodel<cr>
map <Leader>vv :RVview<cr>
map <Leader>w <C-w>w
map <Leader>dt :diffthis<cr>
map <Leader>du :diffu<cr>
nmap <Leader>b :BufExplorer<cr>
" copy path to clipboard
nmap cp :let @+ = expand("%")<cr>
map <C-h> :nohl<cr>
imap <C-r>; <Space>=><Space>
map <C-s> <esc>:w<CR>
imap <C-s> <esc>:w<CR>
map <C-t> <esc>:tabnew<CR>
map <C-x> <C-w>c
map <C-n> :cn<CR>
map <C-p> :cp<CR>
" Prettify JSON. Requires: sudo cpan JSON::XS
map <Leader>jp <Esc>:%!json_xs -f json -t json-pretty<CR>
" Emacs-like beginning and end of line.
imap <c-e> <c-o>$
imap <c-a> <c-o>^
"remap ESC key in insert mode
:inoremap <CR> <Esc>
map<Leader>nolint :autocmd! BufWritePost,FileWritePost *.js<cr>
map<Leader>lint :autocmd! BufWritePost,FileWritePost *.js call JavascriptLint()<cr>
map<Leader>a :Ack! <CR>
set nocompatible
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set autoindent
set showmatch
set nowrap
set backupdir=~/.tmp
set directory=~/.tmp " Don't clutter my dirs up with swp and tmp files
set autoread
set wmh=0
set viminfo+=!
set guioptions-=e
set guioptions-=m
set guioptions-=T
set guifont=Triskweline_10:h10
set et
set sw=2
set smarttab
set noincsearch
set ignorecase smartcase
set laststatus=2 " Always show status line.
set number
set gdefault " assume the /g flag on :s substitutions to replace all matches in a line
set autoindent " always set autoindenting on
set bg=light
let g:SuperTabCrMapping = 0 "Supertab completion is interfering with exiting insert mode
set cursorline "Highlight the line the cursor is on
set clipboard=unnamed
set diffopt=filler,vertical
set ttyfast " Send more characters at a given time.
set scrolloff=3 " Start scrolling three lines before horizontal border of window.
" Speed up viewport scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Strip trailing whitespace (,ss)
function! StripWhitespace ()
let save_cursor = getpos(".")
let old_query = getreg('/')
call setpos('.', save_cursor)
call setreg('/', old_query)
noremap <leader>ss :call StripWhitespace ()<CR>
" Edit another file in the same directory as the current file
" uses expression to extract path from current file's path
map <Leader>e :e <C-R>=expand("%:p:h") . '/'<CR>
map <Leader>s :split <C-R>=expand("%:p:h") . '/'<CR>
map <Leader>v :vnew <C-R>=expand("%:p:h") . '/'<CR>
" Set the tag file search order
set tags=./tags;
" Use _ as a word-separator
" set iskeyword-=_
" Use Ack instead of grep
set grepprg=ack
" Make the omnicomplete text readable
:highlight PmenuSel ctermfg=black
" Fuzzy finder: ignore stuff that can't be opened, and generated files
let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**"
" Highlight the status line
highlight StatusLine ctermfg=blue ctermbg=yellow
" Format xml files
" au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null"
set shiftround " When at 3 spaces and I hit >>, go to 4, not 5.
set nofoldenable " Say no to code folding...
command! Q q " Bind :Q to :q
command! Qall qall
command! Wa wa
set statusline+=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
" Disable that goddamn 'Entering Ex mode. Type 'visual' to go to Normal mode.'
" that I trigger 40x a day.
map Q <Nop>
" Disable K looking stuff up
map K <Nop>
let g:CommandTMaxHeight=50
let g:CommandTMatchWindowAtTop=1
let g:CommandTMaxFiles=20000
" When loading text files, wrap them
au BufNewFile,BufRead *.txt setlocal wrap
" Better? completion on command line
set wildmenu
" What to do when I press 'wildchar'. Worth tweaking to see what feels right.
set wildmode=list:longest,full
" Center search matches when jumping
map N Nzz
map n nzz
" Merge a tab into a split in the previous window
function! MergeTabs()
if tabpagenr() == 1
let bufferName = bufname("%")
if tabpagenr("$") == tabpagenr()
execute "buffer " . bufferName
nmap <C-W>u :call MergeTabs()<CR>
function! CorrectTestRunner()
if match(expand('%'), '\.feature$') != -1
return "cucumber"
elseif match(expand('%'), '_spec\.rb$') != -1
return "rspec"
function! RunCurrentTest()
exec "!" . CorrectTestRunner() . " --drb" . " " . expand('%:p')
function! RunCurrentLineInTest()
exec "!" . CorrectTestRunner() . " --drb" . " " . expand('%:p') . ":" . line(".")
imap <Tab> <C-P>
" Added for ragtag plugin
inoremap <M-o> <Esc>o
inoremap <C-j> <Down>
let g:ragtag_global_maps = 1
" ========================================================================
" End of things set by me.
" ========================================================================
" ========================================================================
" Things set by johnw
" ========================================================================
" yank visual selection to clipboard
:vmap <f12> "+y
" paste from clipboard
:nmap <S-f12> "+p
:colorscheme vividchalk
au TabEnter * call s:ChangeToNerdTreeRoot()
function! s:ChangeToNerdTreeRoot()
if !exists('t:NERDTreeBufName')
let root = getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
let path = root.path.str({'format': 'Cd'})
exec "cd " . path
let g:bufExplorerDetailedHelp=1 " Show detailed help.
let g:bufExplorerShowTabBuffer=1 " Yes.
"Rename tabs to show tab# and # of viewports
if exists("+showtabline")
function! MyTabLine()
let s = ''
let wn = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let wn = tabpagewinnr(i,'$')
let s .= (i== t ? '%#TabNumSel#' : '%#TabNum#')
let s .= i
" Don't show the number of viewports
" if tabpagewinnr(i,'$') > 1
" let s .= '.'
" let s .= (i== t ? '%#TabWinNumSel#' : '%#TabWinNum#')
" let s .= (tabpagewinnr(i,'$') > 1 ? wn : '')
" end
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let bufnr = buflist[winnr - 1]
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.', '', '')
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
let s .= file
let s .= (i == t ? '%m' : '')
let i = i + 1
let s .= '%T%#TabLineFill#%='
return s
set stal=2
set tabline=%!MyTabLine()
set tabpagemax=15
hi TabLineSel term=bold cterm=bold ctermfg=16 ctermbg=229
hi TabWinNumSel term=bold cterm=bold ctermfg=90 ctermbg=229
hi TabNumSel term=bold cterm=bold ctermfg=16 ctermbg=229
hi TabLine term=underline ctermfg=16 ctermbg=145
hi TabWinNum term=bold cterm=bold ctermfg=90 ctermbg=145
hi TabNum term=bold cterm=bold ctermfg=16 ctermbg=145
" ========================================================================
" end things set by johnw
" ========================================================================
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
" For all text files set 'textwidth' to 78 characters.
" This auto-breaks lines, disabling it
" autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
endif " has("autocmd")
Jump to Line
Something went wrong with that request. Please try again.