Skip to content

Instantly share code, notes, and snippets.

@tpope
Created August 19, 2009 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tpope/170560 to your computer and use it in GitHub Desktop.
Save tpope/170560 to your computer and use it in GitHub Desktop.
" hashrocket.vim
" vim:set ft=vim et tw=78 sw=2:
if $HASHROCKET_DIR == '' && expand('<sfile>') =~# '/ops/hashrocket\.vim$'
let $HASHROCKET_DIR = expand('<sfile>')[0 : -20]
endif
if $HASHROCKET_DIR == '' && filereadable(expand('~/.bashrc'))
let $HASHROCKET_DIR = expand(matchstr("\n".join(readfile(expand('~/.bashrc')),"\n")."\n",'\n\%(export\)\=\s*HASHROCKET_DIR="\=\zs.\{-\}\ze"\=\n'))
endif
if $HASHROCKET_DIR == ''
let $HASHROCKET_DIR = substitute(system("bash -i -c 'echo \"$HASHROCKET_DIR\"'"),'\n$','','')
endif
if $HASHROCKET_DIR == ''
let $HASHROCKET_DIR = expand('~/hashrocket')
endif
function! s:HComplete(A,L,P)
let match = split(glob($HASHROCKET_DIR.'/'.a:A.'*'),"\n")
return map(match,'v:val[strlen($HASHROCKET_DIR)+1 : -1]')
endfunction
command! -bar -nargs=1 Hcommand :command! -bar -bang -nargs=1 -complete=customlist,s:HComplete H<args> :<args><lt>bang> $HASHROCKET_DIR/<lt>args>
Hcommand cd
Hcommand lcd
Hcommand read
Hcommand edit
Hcommand split
Hcommand saveas
Hcommand tabedit
command! -bar -range=% Trim :<line1>,<line2>s/\s\+$//e
set nocompatible
set autoindent
set autoread
set backspace=indent,eol,start
set complete-=i " Searching includes can be slow
set display=lastline " When lines are cropped at the screen bottom, show as much as possible
if &grepprg ==# 'grep -n $* /dev/null'
set grepprg=grep\ -rnH\ --exclude='.*.swp'\ --exclude='*~'\ --exclude='*.log'\ --exclude=tags\ $*\ /dev/null
endif
set hlsearch
set incsearch
set laststatus=2 " Always show status line
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set list " show trailing whiteshace and tabs
set scrolloff=1
set sidescrolloff=5
set showcmd
set showmatch
set smarttab
if &statusline == ''
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y%=%-16(\ %l,%c-%v\ %)%P
endif
set ttimeoutlen=50 " Make Esc work faster
set wildmenu
if $TERM == '^\%(screen\|xterm-color\)$' && t_Co == 8
set t_Co=16
endif
let g:is_bash = 1 " Highlight all .sh files as if they were bash
let g:ruby_minlines = 500
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_rails = 1
let g:NERDCreateDefaultMappings = 0
let g:NERDSpaceDelims = 1
let g:NERDShutUp = 1
let g:VCSCommandDisableMappings = 1
let g:surround_{char2nr('s')} = " \r"
let g:surround_indent = 1
command! -bar -nargs=0 SudoW :setl nomod|silent exe 'write !sudo tee % >/dev/null'|let &mod = v:shell_error
command! -bar -nargs=* -bang W :write<bang> <args>
runtime! plugin/matchit.vim
runtime! macros/matchit.vim
map Y y$
nnoremap <silent> <C-L> :nohls<CR><C-L>
inoremap <C-C> <Esc>`^
cnoremap <C-O> <Up>
inoremap ø <C-O>o
inoremap <M-o> <C-O>o
inoremap <C-X><C-@> <C-A>
" Emacs style mappings
inoremap <C-A> <C-O>^
cnoremap <C-A> <Home>
" If at end of a line of spaces, delete back to the previous line.
" Otherwise, <Left>
inoremap <silent> <C-B> <C-R>=getline('.')=~'^\s*$'&&col('.')>strlen(getline('.'))?"0\<Lt>C-D>\<Lt>Esc>kJs":"\<Lt>Left>"<CR>
cnoremap <C-B> <Left>
" If at end of line, decrease indent, else <Del>
inoremap <silent> <C-D> <C-R>=col('.')>strlen(getline('.'))?"\<Lt>C-D>":"\<Lt>Del>"<CR>
cnoremap <C-D> <Del>
" If at end of line, fix indent, else <Right>
inoremap <silent> <C-F> <C-R>=col('.')>strlen(getline('.'))?"\<Lt>C-F>":"\<Lt>Right>"<CR>
inoremap <C-E> <End>
cnoremap <C-F> <Right>
noremap <F1> <Esc>
noremap! <F1> <Esc>
nmap \\ <Plug>NERDCommenterInvert
xmap \\ <Plug>NERDCommenterInvert
" Enable TAB indent and SHIFT-TAB unindent
vnoremap <silent> <TAB> >gv
vnoremap <silent> <S-TAB> <gv
iabbrev Lidsa Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
iabbrev rdebug require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger
syntax on
filetype plugin indent on
augroup hashrocket
autocmd!
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *
\ if isdirectory(expand("<amatch>:h")) | let &swapfile = &modified | endif
autocmd BufNewFile,BufRead *.haml set ft=haml
autocmd BufNewFile,BufRead *.feature,*.story set ft=cucumber
autocmd BufRead * if ! did_filetype() && getline(1)." ".getline(2).
\ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif
autocmd FileType javascript setlocal et sw=2 sts=2 isk+=$
autocmd FileType html,xhtml,css setlocal et sw=2 sts=2
autocmd FileType eruby,yaml,ruby setlocal et sw=2 sts=2
autocmd FileType cucumber setlocal et sw=2 sts=2
autocmd FileType gitcommit setlocal spell
autocmd FileType ruby setlocal comments=:#\ tw=79
autocmd FileType vim setlocal et sw=2 sts=2 keywordprg=:help
autocmd Syntax css syn sync minlines=50
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment