Skip to content

Instantly share code, notes, and snippets.

@jpstokes
Created July 13, 2015 12:35
Show Gist options
  • Save jpstokes/0dcaedc6c2abc1821aa8 to your computer and use it in GitHub Desktop.
Save jpstokes/0dcaedc6c2abc1821aa8 to your computer and use it in GitHub Desktop.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'gmarik/vundle'
" Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-git'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-unimpaired'
Plugin 'mileszs/ack.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'ervandew/supertab'
Plugin 'scrooloose/syntastic'
Plugin 'kchmck/vim-coffee-script'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'ngmy/vim-rubocop'
Plugin 'vim-ruby/vim-ruby'
Plugin 'slim-template/vim-slim'
Plugin 'mattn/gist-vim'
Plugin 'mattn/webapi-vim'
Plugin 'bling/vim-airline'
Plugin 'raimondi/delimitmate'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'thoughtbot/vim-rspec'
Plugin 'jgdavey/tslime.vim'
Plugin 'burnettk/vim-angular'
Plugin 'pangloss/vim-javascript'
" Enable file highlighting and filetype indenting
set background=dark
set regexpengine=1
syntax enable " Enable syntax highlighting
filetype indent on " Enable filetype-specific indenting
" Hack for speeding up vim load when using rvm
let g:ruby_path = system('rvm current')
" Set airline theme
let g:airline_theme='zenburn'
" Send message to tmux pane
let g:rspec_command = 'call Send_to_Tmux("rspec -fd {spec}\n")'
" let g:solarized_termcolors=256
colorscheme darkblue
set number
set shell=/bin/sh
set runtimepath^=~/.vim/bundle/ctrlp.vim
set expandtab tabstop=2 shiftwidth=2
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
set nowrap
let g:ctrlp_working_path_mode = 'ra'
let g:nerdtree_tabs_smart_startup_focus=1
let mapleader = ','
" Basic standards of sanity
set encoding=utf-8
set scrolloff=3
set showmode
set showcmd
set hidden
set wildmode=longest,list
set visualbell
set cursorline
set ttyfast
set backspace=indent,eol,start
set winwidth=80
set smartindent
set tabstop=2
set guioptions-=T
" Preserve large pastes
set pastetoggle=<F2>
" Leader a for ack
nnoremap <Leader>a :Ack
" CTRL-H will convert an erb file to Haml
function! Html2Haml()
let fileext = expand("%:e")
if fileext == "erb"
let filename = expand("%:r")
let current_file = filename . "." . fileext
let tmp_file = tempname()
let new_file = filename . ".haml"
execute "!html2haml " . current_file . " " . tmp_file
exec "silent split " . tmp_file
exec "silent normal GVggy"
exec "silent bunload"
exec "silent normal GVggp"
exec "silent Gmove " . new_file
exec "silent edit!"
endif
endfunction
map <Leader>h :call Html2Haml()<CR>
" Improved history commands
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
" Fix forward searching
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
" Remap Leader w to open and switch to vertical split
nnoremap <Leader>w <C-w>v<C-w>l
set cf " Enable error files & error jumping.
set clipboard=unnamed
set autowrite " Writes on make/shell commands
set ruler " Ruler on
" Visual
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
set list
set lcs=tab:\ \ ,trail:~,extends:&,precedes:<
set novisualbell " No blinking .
set noerrorbells " No noise.
set laststatus=2 " Always show status line.
" gvim specific
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modes
" Ruby autocomplete setup
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" improve autocomplete menu color
highlight Pmenu ctermbg=238 gui=bold
" Statusline config
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
" Taken from Gary Bernhardt's Dotfiles on github
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>rf :call RenameFile()<cr>
function! <SID>FixWhiteSpace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history,
" and cursor position
let @/=_s
call cursor(l, c)
endfunction
nnoremap <silent> <F5> :call <SID>FixWhiteSpace()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ARROW KEYS ARE UNACCEPTABLE
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Left> :echo "no!"<cr>
map <Right> :echo "no!"<cr>
map <Up> :echo "no!"<cr>
map <Down> :echo "no!"<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OPEN FILES IN DIRECTORY OF CURRENT FILE
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Promote Variable to Rspec Let
function! PromoteToLet()
:normal! dd
:normal! P
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
:normal ==
endfunction
:command! PromoteToLet :call PromoteToLet()
:map <Leader>u :PromoteToLet<CR>
if executable('rubocop')
" RuboCop from Anywhere
nmap <Leader>ru :RuboCop<CR>
imap <Leader>ru <ESC>:RuboCop<CR>
endif
" Quickly edit/reload the vimrc file
nmap <silent> <Leader>ev :e $MYVIMRC<CR>
nmap <silent> <Leader>sv :so $MYVIMRC<CR>
" My own customizations
map <Leader>n <plug>NERDTreeTabsToggle<CR>
" Use ctrl-[hjkl] to select the active split!
nmap <silent> <c-k> :wincmd k<CR>
nmap <silent> <c-j> :wincmd j<CR>
nmap <silent> <c-h> :wincmd h<CR>
nmap <silent> <c-l> :wincmd l<CR>
" Git
map <Leader>gb :Gblame<CR>
" vim-rspec mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment