Skip to content

Instantly share code, notes, and snippets.

@cschep
Created July 13, 2015 20:47
Show Gist options
  • Save cschep/42eabff9ee1c7d6c6bda to your computer and use it in GitHub Desktop.
Save cschep/42eabff9ee1c7d6c6bda to your computer and use it in GitHub Desktop.
" this isn't vi and apparently needs to be first?
set nocompatible
" pathogen
call pathogen#infect()
" shift O delay after insert mode? fuuuuu
set timeout timeoutlen=3000 ttimeoutlen=100
" copypaste
set pastetoggle=<c-k>
" filetype stuff
syntax on
filetype plugin indent on
" TODO: understand this
" something about background buffers
" set hidden
" never forget
set history=1000
" all the cool kids do this
let mapleader = ","
" some giant companies with robots hate this
set colorcolumn=80
" what the fuck is ex mode?
map Q <Nop>
" Thank god this exists - jake!
cabbrev W w
cabbrev Q q
cabbrev Wq wq
cabbrev WQ wq
" bash like completion
set wildmenu
set wildmode=list:longest
" numbers and stuff
set number
set numberwidth=4
set ruler
set nowrap
" intuitive (not broken) backspacing in insert mode
set backspace=indent,eol,start
" highlight search terms
set hlsearch
set incsearch " ...dynamically as they are typed.
" Make searches case-sensitive only if they contain upper-case characters
set ignorecase
set smartcase
" colors!
set t_Co=256
set background=dark
"colorscheme solarized
"colorscheme base16-default
"colorscheme spacedust
"colorscheme ir_black
"colorscheme eddie
"colorscheme vividchalk
"colorscheme jellybeans
"colorscheme molokai
" macvim
if has("gui_running")
set guioptions-=e
set guioptions-=r
set guioptions-=L
set guioptions-=T
set guifont=Inconsolata-dz:h12
" set guifont=Menlo:h12
else
colorscheme jellybeans
end
" splits as dashes
:hi VertSplit ctermbg=NONE guibg=NONE
" always show tab bar
set showtabline=2
" temporary files in a central spot
" or just don't make them
set nobackup
set nowritebackup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" GRB: sane editing configuration"
set expandtab
set tabstop=4
set shiftwidth=4
"set softtabstop=4
set autoindent
" set smartindent - what is this?
set laststatus=2
set showmatch
" GRB: Put useful info in status line
set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red
" two spaces
au BufNewFile,BufRead Podfile,*.podspec set filetype=ruby
autocmd FileType coffee,Rakefile,ruby,haml,eruby,yaml,html,css,htmldjango,javascript,sass,cucumber set ai sw=2 sts=2 et
" jump between files
nnoremap <leader><leader> <c-^>
" ctrlp plugin
nnoremap <silent> <leader>t :CtrlP<cr>
nnoremap <silent> <leader>T :ClearCtrlPCache<cr>\|:CtrlP<cr>
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](node_modules)$',
\ }
" show more than 10
let g:ctrlp_max_height = 35
" kill whitespace - does this work?
" :nnoremap <silent> <c-y> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
" no.
map <Left> :echo "no!"<cr>
map <Right> :echo "no!"<cr>
map <Up> :echo "no!"<cr>
map <Down> :echo "no!"<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" function! MapCR()
" nnoremap <cr> :call RunTestFile()<cr>
" endfunction
" call MapCR()
" nnoremap <leader>T :call RunNearestTest()<cr>
" nnoremap <leader>a :call RunTests('')<cr>
" " nnoremap <leader>c :w\|:!script/features<cr>
" " nnoremap <leader>w :w\|:!script/features --profile wip<cr>
" 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_test_file = match(expand("%"), '\(.feature\|Spec.js|_spec.rb\|_test.py\)$') != -1
" if in_test_file
" call SetTestFile(command_suffix)
" 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
" function! SetTestFile(command_suffix)
" " Set the spec file that tests will be run for.
" echo "setting test file"
" let t:grb_test_file=@% . a:command_suffix
" endfunction
" function! RunTests(filename)
" " Write the file and run tests for the given filename
" if expand("%") != ""
" :w
" end
" if match(a:filename, '\.feature$') != -1
" exec ":!script/features " . a:filename
" else
" " First choice: project-specific test script
" if filereadable("script/test")
" exec ":!script/test " . a:filename
" " Fall back to the .test-commands pipe if available, assuming someone
" " is reading the other side and running the commands
" elseif filewritable(".test-commands")
" let cmd = 'rspec --color --format progress --require "~/lib/vim_rspec_formatter" --format VimFormatter --out tmp/quickfix'
" exec ":!echo " . cmd . " " . a:filename . " > .test-commands"
" " Write an empty string to block until the command completes
" sleep 100m " milliseconds
" :!echo > .test-commands
" redraw!
" " Fall back to a blocking test run with Bundler
" elseif filereadable("Gemfile")
" exec ":!bundle exec rspec --color " . a:filename
" " If we see python-looking tests, assume they should be run with Nose
" elseif strlen(glob("test/**/*.py") . glob("tests/**/*.py"))
" exec "!nosetests " . a:filename
" " If we see javascript-looking tests, assume they should be run with Mocha
" elseif strlen(glob("test/**/*.js") . glob("tests/**/*.js") . glob("spec/**/*.js"))
" exec "!mocha " . a:filename
" " Fall back to a normal blocking test run
" else
" exec ":!rspec --color " . a:filename
" end
" end
" endfunction
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" NERDTree
map <C-n> :NERDTreeToggle<CR>
" STFU
set noerrorbells visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
" surround in quotes
:nnoremap <leader>" viw<esc>a"<esc>hbi"<esc>lel
" move to the beginning of the line
:nnoremap H 0
" move to the end of the line
:nnoremap L $
" open vimrc in vertical split
:nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" source vimrc
:nnoremap <leader>sv :source $MYVIMRC<cr>
" hmm k
:inoremap jk <esc>
" :inoremap <esc> <nop>
" python test running for a project
" better way to do this on a per project basis?
" map <leader>a :w\|!python test_runner.py<cr>
" run ruby
" map <leader>f :w\|!ruby %<cr>
" run current file as bundle exec rspec
" map <leader>r :w\|!bundle exec rspec --no-color %<cr>
" run current file as python
" map <leader>r :w\|!python %<cr>
" run current file as javascript
map <leader>r :w\|!node %<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment