Skip to content

Instantly share code, notes, and snippets.

@cmaher
Last active December 9, 2015 20:38
Show Gist options
  • Save cmaher/4324794 to your computer and use it in GitHub Desktop.
Save cmaher/4324794 to your computer and use it in GitHub Desktop.
" enable some stuff
set nocompatible
"enable pathogen
call pathogen#infect()
"open files relative to current file
cnoremap <C-E> edit <C-R>=expand("%:h")<CR>/
" turn on proper file recognition
filetype on
filetype plugin on
filetype plugin indent on
" turn on syntax for the filetype
syntax on
syntax enable
" display the command that is being entered
set showcmd
" auto-indenting for convenience
set autoindent
" expanding tab to spaces
set expandtab
set smarttab
" 4 spaces for tab
set shiftwidth=4
set tabstop=4
" line numbers
set number
" make searching easier on the case treatement
set ignorecase
set smartcase
" incremental search
set incsearch
" highlight all search results
set hlsearch
set nohidden
" type jk instead of escape
inoremap jk <Esc>
"keep at least 5 lines below
set scrolloff=5
" folding based on the language used -- za to fold
set foldmethod=syntax
set foldlevelstart=20
" better fold highlighting
hi Folded ctermfg=5 ctermbg=2
" better search highlighting
hi Search ctermfg=0 ctermbg=5
" clear search term, thus clearing highlighting
nnoremap <silent> \h :let @/="" <CR>
" disable word-wrap
set nowrap
" copy/paste to clipboard
nnoremap \a ggVG
nnoremap \p "+p
vnoremap \p "+p
vnoremap \y "+y
vnoremap \d "+d
"""""""""""""" CoffeeScript
"compile coffeescript on write
au BufWritePost *.coffee silent CoffeeMake! -b | cwindow | redraw!
""""""""""""""" Ruby
" Execute open rspec buffer
function! RunSpec(args)
let spec = "rspec"
let cmd = ":! " . spec . " " . a:args
execute cmd
endfunction
" run one rspec example or describe block based on cursor position
map \s :call RunSpec("-l " . <C-r>=line('.')<CR>)
" run full rspec file
map \S :call RunSpec("")<CR>
" sudo overwrite files
cmap w!! %!sudo tee > /dev/null %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment