2011-05-03 21:53:50 -07:00
|
|
|
" ~/.vimrc
|
2012-07-20 09:48:27 -07:00
|
|
|
" Eryn Wells <eryn@erynwells.me>
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
set nocompatible "use enhanced vim features
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2013-10-02 09:11:34 -07:00
|
|
|
execute pathogen#infect()
|
2011-08-15 10:44:30 -07:00
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
set autoread "reread files changed outside of vim
|
|
|
|
set noautowrite "don't write files before commands like :next and :make
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
set ffs=unix,dos,mac "order of line ending formats to try
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2011-08-15 10:44:30 -07:00
|
|
|
set hidden " allow hidden buffers (rather than closing them)
|
|
|
|
|
|
|
|
set number " show line numbers
|
2012-09-28 19:47:51 -07:00
|
|
|
"set relativenumber " line numbers are relative to current line rather
|
2011-09-13 11:22:16 -07:00
|
|
|
" than absolute
|
2011-08-15 10:44:30 -07:00
|
|
|
set ruler " show ruler (line and col count)
|
|
|
|
set showmode " show mode
|
|
|
|
set showcmd " show last command
|
|
|
|
set title " change terminal title
|
|
|
|
set visualbell " don't beep
|
|
|
|
set noerrorbells " PLEASE don't beep
|
2011-09-13 11:22:16 -07:00
|
|
|
set ttyfast " fast terminals
|
2011-08-15 10:44:30 -07:00
|
|
|
|
2011-11-30 13:21:59 -08:00
|
|
|
set wrap " wrap long lines
|
2011-08-15 10:44:30 -07:00
|
|
|
set linebreak " break at between words
|
2013-08-07 22:43:43 -07:00
|
|
|
set textwidth=120 " wrap at 120 characters
|
|
|
|
set colorcolumn=80,120 " highlight 80th and 120th columns
|
2011-08-15 10:44:30 -07:00
|
|
|
set showmatch " show matching things: (), {}, [], etc
|
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
set fo+=n " format numbered lists properly
|
2011-08-15 10:44:30 -07:00
|
|
|
|
2012-11-01 10:52:21 -07:00
|
|
|
set nolist " don't show spaces, newlines, etc by default
|
2011-09-13 12:29:53 -07:00
|
|
|
set lcs+=tab:▸\ " show tabs
|
|
|
|
set lcs+=eol:¬ " show end-of-lines
|
|
|
|
set lcs+=trail:・ " show trailing spaces
|
|
|
|
set lcs+=extends:→ " show long lines (that go offscreen)
|
2011-11-30 13:21:59 -08:00
|
|
|
set lcs+=nbsp:・ " show non-breaking spaces
|
2011-08-15 10:44:30 -07:00
|
|
|
|
|
|
|
set ignorecase " ignore case in searches
|
|
|
|
set smartcase " case-sensitive search if pattern contains a capital
|
|
|
|
set incsearch " show search matches as you type
|
2011-09-13 11:22:16 -07:00
|
|
|
set gdefault " apply searches globally to a line by default
|
2011-08-17 10:14:52 -07:00
|
|
|
|
2012-12-04 10:47:52 -08:00
|
|
|
set laststatus=2 " always show status line
|
|
|
|
|
|
|
|
" This is basically default status line, with a few exceptions:
|
2013-01-03 10:57:25 -08:00
|
|
|
" 1. Show buffer number before filename (%n:)
|
|
|
|
" 2. Show filetype between line number and percentage
|
|
|
|
set statusline=%2n:%<%f\ %((%Y)%)\ %(%h%m%r%)%=%-12(%l,%c%V%)%P
|
2012-12-04 10:47:52 -08:00
|
|
|
|
2011-08-17 10:14:52 -07:00
|
|
|
" use PCREs for searches
|
|
|
|
nnoremap / /\v
|
|
|
|
vnoremap / /\v
|
2011-08-15 10:44:30 -07:00
|
|
|
|
|
|
|
set spelllang=en " set spelling language
|
2011-05-03 21:53:50 -07:00
|
|
|
if has('win32') || has('win64')
|
|
|
|
set spellfile=~/_vim/spelling.en.add
|
|
|
|
else
|
|
|
|
set spellfile=~/.vim/spelling.en.add
|
|
|
|
endif
|
|
|
|
|
2012-07-20 09:48:27 -07:00
|
|
|
set noswapfile " don't keep swap files
|
|
|
|
set nobackup " don't keep backup files
|
|
|
|
set backupdir=~/.vim/backup
|
|
|
|
" save backup files here
|
2011-09-13 11:22:16 -07:00
|
|
|
set undofile " save undo history
|
|
|
|
set undodir=~/.vim/undo " save undo files here
|
2011-08-15 10:44:30 -07:00
|
|
|
set history=1000 " remember 1000 commands in history
|
|
|
|
set undolevels=1000 " keep lots of undo history
|
2011-05-03 21:53:50 -07:00
|
|
|
set viminfo=%100,'100,/100,h,\"500,:100,n~/.viminfo
|
2011-08-15 10:44:30 -07:00
|
|
|
" I have *NO* idea what this does...
|
2011-05-03 21:53:50 -07:00
|
|
|
|
|
|
|
set backspace=indent,eol,start
|
2011-08-15 10:44:30 -07:00
|
|
|
" backspace over everything in insert mode
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2011-08-15 10:44:30 -07:00
|
|
|
set tabstop=8 " tabs are always 8 spaces
|
|
|
|
set shiftwidth=4 " shift lines 4 spaces with >> and <<
|
|
|
|
set softtabstop=4 " tab key inserts 4 spaces
|
|
|
|
set shiftround " round off indent to multiple of shiftwidth
|
2011-09-13 11:22:16 -07:00
|
|
|
set expandtab " always use spaces
|
2011-08-15 10:44:30 -07:00
|
|
|
set nojoinspaces " insert 1 space instead of 2 after punctuation on line
|
|
|
|
" join
|
|
|
|
set autoindent " always use autoindenting
|
|
|
|
set copyindent " copy previous indentation on autoindent
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2011-08-15 10:44:30 -07:00
|
|
|
set scrolloff=3 " scroll 3 lines ahead of point
|
|
|
|
set sidescrolloff=5 " scroll 5 columns ahead of point
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2013-01-03 10:57:25 -08:00
|
|
|
set pastetoggle=<F12> " toggle paste mode with F12
|
2011-05-03 21:53:50 -07:00
|
|
|
|
|
|
|
" completion menu
|
|
|
|
set wildmenu
|
|
|
|
set wildmode=longest,list
|
2012-09-28 19:47:51 -07:00
|
|
|
|
|
|
|
" Wild ignores
|
|
|
|
" build artifacts
|
2013-08-07 22:43:53 -07:00
|
|
|
set wildignore+=*.o,*.pyc,*~,.lo,*.class
|
2012-09-28 19:47:51 -07:00
|
|
|
set wildignore+=*.db,*.pdf,*.jpg,*.jpeg,*.png,*.gif
|
|
|
|
set wildignore+=.git,env,migrations
|
2011-05-03 21:53:50 -07:00
|
|
|
|
|
|
|
if has('mouse')
|
|
|
|
set mouse=a
|
|
|
|
endif
|
|
|
|
|
|
|
|
set modeline
|
|
|
|
set modelines=12
|
|
|
|
|
2013-01-23 13:24:37 -08:00
|
|
|
" Add my generated system tags files
|
|
|
|
set tags=./tags,tags
|
|
|
|
" These two are the important ones
|
|
|
|
set tags+=~/.tags/apple_frameworks.tags
|
|
|
|
set tags+=~/.tags/usr.tags
|
|
|
|
"set tags+=~/.tags/3rdparty_frameworks.tags
|
|
|
|
" This thing is 853 MB on my last count. It *probably* doesn't need to be
|
|
|
|
" included all the time...
|
|
|
|
"set tags+=~/.tags/usr_local.tags
|
|
|
|
|
|
|
|
|
2012-03-21 10:07:19 -07:00
|
|
|
" use syntax highlighting if the terminal can support it (or we're in a GUI)
|
|
|
|
if &t_Co > 2 || has('gui_running')
|
|
|
|
syntax on " turn on syntax highlighting
|
|
|
|
endif
|
|
|
|
|
2013-01-07 10:12:43 -08:00
|
|
|
set bg=dark
|
2012-11-01 10:16:14 -07:00
|
|
|
|
2012-04-10 10:11:38 -07:00
|
|
|
" use solarized colorscheme if the terminal can support it (or we're in a GUI)
|
2013-01-03 10:57:25 -08:00
|
|
|
let g:solarized_termtrans = 1
|
|
|
|
let g:solarized_visibility = 'low'
|
2012-08-07 13:10:45 -07:00
|
|
|
colorscheme solarized
|
2011-08-15 10:44:30 -07:00
|
|
|
|
2011-05-03 21:53:50 -07:00
|
|
|
" tell SnipMate who I am
|
2011-09-13 11:22:16 -07:00
|
|
|
let g:snips_author = 'Eryn Wells <eryn@erynwells.me>'
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2012-01-24 13:19:24 -08:00
|
|
|
" set the Gundo preview window on the bottom
|
|
|
|
let g:gundo_preview_bottom = 1
|
|
|
|
|
2013-01-03 10:57:25 -08:00
|
|
|
map <silent> <F2> :NERDTreeToggle<CR>
|
2013-01-07 10:13:30 -08:00
|
|
|
map <silent> <F3> :GundoToggle<CR>
|
2013-01-03 10:57:25 -08:00
|
|
|
map <silent> <F4> :setlocal invlist<CR>
|
2011-07-29 07:48:33 -07:00
|
|
|
|
2012-11-01 10:16:14 -07:00
|
|
|
inoremap jj <ESC>
|
|
|
|
|
2011-08-15 10:44:30 -07:00
|
|
|
" allow starting commands with ; instead of :
|
|
|
|
nnoremap ; :
|
|
|
|
|
|
|
|
" tab to skip between braces and such in normal
|
|
|
|
nnoremap <tab> %
|
|
|
|
vnoremap <tab> %
|
|
|
|
|
|
|
|
" disable the help key!
|
|
|
|
inoremap <F1> <ESC>
|
|
|
|
nnoremap <F1> <ESC>
|
|
|
|
vnoremap <F1> <ESC>
|
|
|
|
|
|
|
|
" make switching windows easier
|
|
|
|
nnoremap <C-h> <C-w>h
|
|
|
|
nnoremap <C-j> <C-w>j
|
|
|
|
nnoremap <C-k> <C-w>k
|
|
|
|
nnoremap <C-l> <C-w>l
|
|
|
|
|
2013-03-06 09:15:40 -08:00
|
|
|
" Usual EMACS (oh the horror!) begin-line and end-line keys for first and last
|
|
|
|
" buffer.
|
|
|
|
"nnoremap <silent> <C-a> :bfirst<CR>
|
|
|
|
"nnoremap <silent> <C-e> :blast<CR>
|
|
|
|
" Move between buffers with <C-n> and <C-p>
|
2013-01-03 10:57:25 -08:00
|
|
|
nnoremap <silent> <C-n> :bn<CR>
|
|
|
|
nnoremap <silent> <C-p> :bp<CR>
|
|
|
|
|
2013-01-13 10:12:34 -08:00
|
|
|
|
|
|
|
function! <SID>strip_trailing_whitespace()
|
2011-09-16 11:27:20 -07:00
|
|
|
" save last search
|
|
|
|
let _s=@/
|
|
|
|
" save cursor position
|
|
|
|
let l = line('.')
|
|
|
|
let c = col('.')
|
|
|
|
" do the clean up
|
|
|
|
%s/\s\+$//e
|
|
|
|
" restore saved stuff
|
|
|
|
let @/=_s
|
|
|
|
call cursor(l, c)
|
|
|
|
endfunction
|
|
|
|
|
2013-03-12 11:03:11 -07:00
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
function! <SID>FindProjectFileOrDirectory(fod)
|
2013-01-13 10:12:34 -08:00
|
|
|
let l:dir = getcwd()
|
2013-01-16 21:07:53 -08:00
|
|
|
" Search up the path, starting at the current working directory, for the
|
|
|
|
" file or directory given in a:fod and return the path to it, if it exists.
|
|
|
|
while l:dir != "/"
|
|
|
|
let l:file_or_dir = l:dir . "/" . a:fod
|
|
|
|
if filereadable(l:file_or_dir) || isdirectory(l:file_or_dir)
|
|
|
|
return l:file_or_dir
|
2013-01-13 10:12:34 -08:00
|
|
|
endif
|
|
|
|
let l:dir = fnamemodify(l:dir, ':h')
|
|
|
|
endwhile
|
2013-01-16 21:07:53 -08:00
|
|
|
return ""
|
2013-01-13 10:12:34 -08:00
|
|
|
endfunction
|
|
|
|
|
2013-03-12 11:03:11 -07:00
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
function! GetProjectRuntimeDirectory()
|
|
|
|
return <SID>FindProjectFileOrDirectory("vim")
|
|
|
|
endfunction
|
2013-01-13 10:12:34 -08:00
|
|
|
|
2013-03-12 11:03:11 -07:00
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
function! GetProjectFile()
|
|
|
|
return <SID>FindProjectFileOrDirectory("project.vim")
|
|
|
|
endfunction
|
|
|
|
|
2013-03-12 11:03:11 -07:00
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
function! <SID>SourceProjectFile()
|
|
|
|
let l:project_file = GetProjectFile()
|
|
|
|
if l:project_file != ""
|
|
|
|
exec "source " . l:project_file
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2013-03-12 11:03:11 -07:00
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
function! <SID>AddProjectRuntimeDirectory()
|
|
|
|
let l:project_rtp = GetProjectRuntimeDirectory()
|
|
|
|
if isdirectory(l:project_rtp)
|
|
|
|
exec "set rtp+=" . l:project_rtp
|
2013-01-13 10:12:34 -08:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2011-05-03 21:53:50 -07:00
|
|
|
let mapleader=','
|
2013-01-16 21:07:53 -08:00
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
" strip all trailing whitespace in the current file
|
2013-01-13 10:12:34 -08:00
|
|
|
nnoremap <silent> <leader>W :call <SID>strip_trailing_whitespace()<CR>
|
|
|
|
|
2013-01-16 21:07:53 -08:00
|
|
|
" Source .vimrc and project.vim files
|
|
|
|
nmap <leader>V :source $MYVIMRC<CR>
|
|
|
|
nmap <leader>P :call <SID>SourceProjectFile()<CR>
|
|
|
|
" Edit my .vimrc and project.vim files
|
|
|
|
nmap <leader>eV :edit $MYVIMRC<CR>
|
|
|
|
nmap <leader>eP :exec 'edit ' . GetProjectFile()<CR>
|
2013-01-13 10:12:34 -08:00
|
|
|
|
2011-09-13 11:22:16 -07:00
|
|
|
" hide search terms
|
2013-01-03 10:57:25 -08:00
|
|
|
nmap <silent> <leader><space> :setlocal invhlsearch<CR>
|
2011-09-13 11:22:16 -07:00
|
|
|
" find all
|
|
|
|
nmap <leader>fa :%s/\v
|
2011-09-16 11:27:20 -07:00
|
|
|
|
2013-01-07 09:55:13 -08:00
|
|
|
" Open the snippet file for the current filetype
|
2013-03-24 19:02:05 -07:00
|
|
|
nmap <leader>esn :e ~/.vim/bundle/snipmate-snippets/snippets/<C-r>=&filetype<CR>.snippets<CR>
|
2013-01-07 09:55:13 -08:00
|
|
|
" Open the ftplugin-after script for the current filetype
|
|
|
|
nmap <leader>eft :e ~/.vim/after/ftplugin/<C-r>=&filetype<CR>.vim<CR>
|
2011-12-16 16:11:21 -08:00
|
|
|
|
2012-11-01 10:16:14 -07:00
|
|
|
" Toggle position highlighting
|
2013-01-03 10:57:25 -08:00
|
|
|
nmap <silent> <leader>cl :setlocal invcursorline<CR>
|
|
|
|
nmap <silent> <leader>cc :setlocal invcursorcolumn<CR>
|
2012-11-01 10:16:14 -07:00
|
|
|
|
|
|
|
|
2013-01-05 10:28:42 -08:00
|
|
|
" Text bubbling (these depend on tpope's unimpaired plugin)
|
|
|
|
nmap <C-Up> [e
|
|
|
|
nmap <C-Down> ]e
|
|
|
|
vmap <C-Up> [egv
|
|
|
|
vmap <C-Down> ]egv
|
|
|
|
|
|
|
|
" Select last edited text after cut and paste
|
|
|
|
nmap gV `[v`]
|
|
|
|
|
|
|
|
|
2012-03-09 23:37:14 -08:00
|
|
|
" Command-T should open files in tabs when I hit <CR>; move opening files in
|
|
|
|
" buffers to <C-b>
|
2013-01-07 10:13:30 -08:00
|
|
|
"let g:CommandTAcceptSelectionMap='<C-b>'
|
|
|
|
"let g:CommandTAcceptSelectionTabMap='<CR>'
|
2011-09-16 11:27:20 -07:00
|
|
|
|
2013-03-06 09:15:40 -08:00
|
|
|
" GitGutter shows changed lines in files.
|
|
|
|
let g:gitgutter_enabled = 0
|
|
|
|
highlight clear SignColumn
|
|
|
|
nmap <silent> <leader>gg :ToggleGitGutter<CR>
|
|
|
|
|
2011-09-16 11:27:20 -07:00
|
|
|
if has('autocmd')
|
|
|
|
filetype plugin indent on
|
2011-10-20 08:19:42 -07:00
|
|
|
|
2011-09-16 11:27:20 -07:00
|
|
|
" Jump to last known cursor position unless it's the first line, or past the
|
|
|
|
" end of the file
|
|
|
|
autocmd BufReadPost *
|
|
|
|
\ if line("'\"") > 1 && line("'\"") <= line("$") |
|
|
|
|
\ exe "normal! g`\"" |
|
|
|
|
\ endif
|
|
|
|
|
2013-01-13 10:12:34 -08:00
|
|
|
" All my projects are in the ~/Code directory. Look for and source a
|
|
|
|
" project.vim file if one exists.
|
|
|
|
autocmd VimEnter ~/Code/*
|
2013-01-16 21:07:53 -08:00
|
|
|
\ call <SID>SourceProjectFile()
|
|
|
|
autocmd VimEnter ~/Code/*
|
|
|
|
\ call <SID>AddProjectRuntimeDirectory()
|
2013-01-13 10:12:34 -08:00
|
|
|
|
2013-01-07 09:56:12 -08:00
|
|
|
" Reload snippets after editing the snippets file. Snippet files are
|
|
|
|
" <filetype>.snippets. Get <filetype> from the filename and reload the
|
|
|
|
" snippets for that type.
|
2013-01-16 21:07:53 -08:00
|
|
|
"autocmd BufWritePost *.snippets
|
|
|
|
" \ :call ReloadSnippets(expand('%:t:r'))
|
2013-01-07 10:02:47 -08:00
|
|
|
|
2012-07-20 09:48:27 -07:00
|
|
|
" Clean whitespace before saving: Python, C, HTML, and Objective-C
|
2013-08-07 22:43:53 -07:00
|
|
|
autocmd BufWritePre *.py,*.h,*.c,*.html,*.m,*.mm,*.cc,*.hh,*.java
|
2013-01-13 10:12:34 -08:00
|
|
|
\ call <SID>strip_trailing_whitespace()
|
2011-09-16 11:27:20 -07:00
|
|
|
endif
|
2012-01-04 08:55:00 -08:00
|
|
|
|
2012-11-01 10:16:14 -07:00
|
|
|
if has('unix')
|
|
|
|
if filereadable($HOME."/.vimrc.local")
|
|
|
|
source $HOME/.vimrc.local
|
|
|
|
endif
|
2012-01-04 08:55:00 -08:00
|
|
|
endif
|