Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Created February 2, 2013 21:56
Show Gist options
  • Save rewinfrey/4699452 to your computer and use it in GitHub Desktop.
Save rewinfrey/4699452 to your computer and use it in GitHub Desktop.
vimrc for Ryan
" Maintained by Rick Winfrey " heavily borrowed from Vincent Driessen's .vimrc file: https://raw.github.com/nvie/vimrc/master/vimrc
" and http://stevelosh.com/blog/2010/09/coming-home-to-vim/#scratch
set nocompatible
call pathogen#infect()
call pathogen#helptags()
filetype off " force reloading *after* pathogen loaded
filetype plugin indent on " enable detection, plugins and indenting in one step
syntax on
syntax enable
set rtp+=/usr/local/go/misc/vim
set runtimepath^=~/.vim/bundle/ctrlp.vim
" edits behavior
set showmode " always show the current Vim mode
set hidden " hides buffers rather than closing them
set wildignore=*.swp,*.bak,*.pyc,*.class " ignores these file types
" tabs & indentation
set tabstop=2 " tabs are 2 spaces
set expandtab " use spaces, not tabs (optional)
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set shiftwidth=2 " number of spaces used by autoindenting
set autoindent " default autoindent to on
set copyindent " copy previous indentation on autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
" display
set encoding=utf-8 " sets default encoding type to UTF-8
set scrolloff=3
set title
set number " show line numbers by default
set relativenumber " shows how far away lines are from the current line
set backspace=indent,eol,start " backspace through everything in insert mode
set scrolloff=10 " adds top/bottom buffer between cursor and window
" cursor
set cursorline " colours the line the cursor is on
" default colors for CursorLine
" highlight CursorLine ctermbg=Gray ctermfg=Black
" change color of CursorLine when entering insert mode
" autocmd InsertEnter * highlight CursorLine ctermbg=Blue ctermfg=Yellow
" reverts color back to default when leaving insert mode
" autocmd InsertLeave * highlight CursorLine ctermbg=Gray ctermfg=Black
" command history / undo
set history=1000 " because where do we know where we are going, if we do not know where we have been?
set undolevels=1000 " undo a friday night of drunken coding
" alerts
set visualbell
set noerrorbells
" searching
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set gdefault " search / replace 'globally' (on a line) by default
set showmatch " set show matching parenthesis
" line wrapping
set nowrap
set formatoptions=qrn1
" set colorcolumn=100
" don't let Vim backup
set nobackup
set noswapfile
set nowritebackup
" colorscheme
set t_Co=256
set background=dark
colorscheme solarized
" Change the mapleader from \ to ,
let mapleader=","
let maplocalleader="\\"
" makes regex searches use ruby regex patterns
nnoremap / /\v
vnoremap / /\v
" ,<space> turns off search highlighting
nnoremap <leader><space> :noh<cr>
" navigate braces with <tab> rather than mother-f'ing hard to type %
nnoremap <tab> %
vnoremap <tab> %
" edit and load vimrc
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
nnoremap <leader>i :set list!<CR>
nnoremap <leader>N :setlocal relativenumber!<CR>
nnoremap <leader>B :setlocal number!<CR>
" adds require 'pry'; binding.pry to a line
nmap <Leader>y orequire "pry"<CR>binding.pry<ESC>;
" Powerline, toolbar (https://github.com/Lokaltog/vim-powerline/)
let g:Powerline_symbols = 'compatible'
let g:Powerline_stl_path_style = 'relative'
set laststatus=2 " Always show the statusline
" got this list from here: https://github.com/Lokaltog/vim-powerline/blob/c4b72c5be57b165bb6a89d0b8a974fe62c0091d0/autoload/Powerline/Themes/default.vim
call Pl#Theme#RemoveSegment('fugitive:branch')
call Pl#Theme#RemoveSegment('syntastic:errors')
call Pl#Theme#RemoveSegment('fileformat')
call Pl#Theme#RemoveSegment('fileencoding')
call Pl#Theme#RemoveSegment('filetype')
call Pl#Theme#RemoveSegment('lineinfo')
" Slime
let g:slime_target = "screen"
let g:slime_paste_file = "$HOME/.slime_paste"
" easier navigation between split windows
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
:set guifont=Dejavusans:h18
"" filetypes
au BufRead,BufNewFile *.rabl setfiletype ruby " .rabl -> ruby
"" strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" 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
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" replaces %/ with current directory, and %% with current file
cmap %/ <C-R>=expand("%:p:h")."/"<CR>
cmap %% <C-R>=expand("%")<CR>
" .vm, from TECS, should be highlighted with assembly
au BufNewFile,BufRead *.vm set filetype=asm
au BufNewFile,BufRead *.jack set filetype=java "not really, but close enough
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-=> <C-w>=
"command NT NERDTree
"command NT NERDTree NERDTree
" strip all trailing whitespaces from a file, using ,w
nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
" Control P settings
let g:ctrlp_switch_buffer = 'Et'
let g:ctrlp_open_new_file = 'v'
" NERDTree settings
nnoremap <leader>n :NERDTreeClose<CR> :NERDTreeToggle<CR>
nnoremap <leader>m :NERDTreeClose<CR> :NERDTreeFind<CR>
nnoremap <leader>N :NERDTreeClose<CR>
" Show hidden files
let NERDTreeShowFiles=1
let NERDTreeShowHidden=1
" Highlight the current file in NT
let NERDTreeHighlightCursorLine=1
" Use a single click to fold/unfold directories and a double clickt open files
let NERDTreeMouseMode=2
" shift-h to move to front of line
nnoremap H 0
" shift-l to move to back of line
nnoremap L $
" run tests
inoremap <leader>w <esc>:write<CR>:!./run_tests.rb %<CR>
nnoremap <leader>w :!./run_tests.rb<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment