1 " ---------------------------------------------------------------------------
3 " ---------------------------------------------------------------------------
5 set nocompatible " essential
6 set history=1000 " lots of command line history
7 set confirm " error files / jumping
8 set fileformats=unix,dos,mac " support these files
9 set iskeyword+=_,$,@,%,#,- " none word dividers
10 set viminfo='1000,f1,:100,@100,/20
11 set modeline " make sure modeline support is enabled
12 set autoread " reload files (no local changes only)
14 " ---------------------------------------------------------------------------
15 " Pathogen Init (Bundles)
16 " ---------------------------------------------------------------------------
18 call pathogen#infect()
19 call pathogen#helptags()
20 filetype plugin indent on " enable plugins, detection and indenting in one step
22 " ---------------------------------------------------------------------------
24 " ---------------------------------------------------------------------------
26 if &t_Co > 2 || has("gui_running")
29 set t_AB=
\e[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
30 set t_AF=
\e[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
37 set background=dark " dark background
38 syntax enable " syntax highligting
40 " Define to-do color(s)
41 if !exists("autocmd_colorscheme_loaded")
42 let autocmd_colorscheme_loaded = 1
43 autocmd ColorScheme * highlight TodoRed ctermbg=LightRed guibg=#E01B1B ctermfg=White guifg=#002b37
46 " Solarized color-scheme
47 let g:solarized_termtrans=1 " Always use terminal's default bg color
50 " Auto-highlight TODO's
53 autocmd Syntax * call matchadd('TodoRed', '\W\zs\(TODO\)')
58 " ---------------------------------------------------------------------------
60 " ---------------------------------------------------------------------------
63 highlight Comment ctermfg=DarkGrey guifg=#425257
65 highlight Visual term=reverse cterm=reverse ctermfg=DarkGreen ctermbg=White guifg=#4d830a guibg=#ffffff
66 " statusline (active vs inactive)
67 highlight StatusLine term=reverse cterm=reverse ctermfg=DarkGrey ctermbg=Grey guifg=#444444 guibg=#aaaaaa
68 highlight StatusLineNC term=reverse cterm=reverse ctermfg=DarkGrey ctermbg=Black guifg=#444444 guibg=#666666
69 " unprintable chars (listchars)
70 highlight SpecialKey ctermfg=DarkGray ctermbg=Black guifg=#374549 guibg=#010c0e
72 " ----------------------------------------------------------------------------
74 " ----------------------------------------------------------------------------
76 set nobackup " do not keep backups after close
77 set nowritebackup " do not keep a backup while working
78 set backupcopy=yes " keep attributes of original file
79 set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
80 set directory=.,~/tmp,~/.vim/swap " swap file directory-order
82 " ----------------------------------------------------------------------------
84 " ----------------------------------------------------------------------------
86 set ruler " show the cursor position all the time
87 set showcmd " display incomplete commands
88 set nolazyredraw " turn off lazy redraw
89 set hidden " keep buffers loaded when hidden
90 set showmode " show mode at bottom of screen
91 set wildmenu " turn on wild menu
92 set wildmode=list:longest,full
93 set cmdheight=2 " command line height
94 set backspace=2 " allow backspacing over everything in insert mode
95 set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
96 set shortmess=filtIoO " shorten messages
97 set report=0 " tell us about changes
98 set nostartofline " don't jump to the start of line when scrolling
99 set scrolloff=4 " vertcal padding
100 set sidescroll=40 " side-scrolling increment (for nowrap mode)
101 set sidescrolloff=10 " horz padding
103 " ----------------------------------------------------------------------------
105 " ----------------------------------------------------------------------------
107 set showmatch " brackets/braces that is
108 set matchtime=5 " duration to show matching brace (1/10 sec)
109 set incsearch " do incremental searching
110 set laststatus=2 " always show the status line
111 set ignorecase " ignore case when searching
112 set smartcase " case-sensitive if search contains an uppercase character
113 set visualbell " shut the heck up
114 set hlsearch " highlight all search matches
115 set list listchars=trail:.,tab:>. " show trailing whitespace and tab chars
117 " ----------------------------------------------------------------------------
119 " ----------------------------------------------------------------------------
121 set statusline=\ %n\ %<%f " buffer #, filename
122 set statusline+=\ %h%m%r " file-state flags
123 set statusline+=%= " left-right divider
124 set statusline+=%{strlen(&fenc)?&fenc:&enc},%{&ff}\ %y " file-encoding, format, type
125 set statusline+=\ %12.(%v,%l/%L%)\ \ %-4P " cursor position, % through file of viewport
127 " ----------------------------------------------------------------------------
129 " ----------------------------------------------------------------------------
131 set autoindent " automatic indent new lines
132 set smartindent " be smart about it
133 set nowrap " do not wrap lines
134 set softtabstop=2 " yep, two
135 set shiftwidth=2 " ..
137 set expandtab " expand tabs to spaces
138 set smarttab " smarter softtab handling
139 set formatoptions+=n " support for numbered/bullet lists
140 set textwidth=0 " no line-wrapping by default
141 set virtualedit=block " allow virtual edit in visual block ..
143 " ----------------------------------------------------------------------------
144 " Filename exclusions
145 " ----------------------------------------------------------------------------
147 set wildignore+=.hg,.git,.svn " version control directories
148 set wildignore+=*.jpg,*.jpeg,*.bmp,*.gif,*.png " image files
149 set wildignore+=*.o,*.obj,*.exe,*.dll " compiled object files
150 set wildignore+=*.pyc " Python byte code
151 set wildignore+=*.sw? " Vim swap files
152 set wildignore+=.DS_Store " OSX junk
154 " ----------------------------------------------------------------------------
156 " ----------------------------------------------------------------------------
159 set tabpagemax=50 " open 50 tabs max
162 " ----------------------------------------------------------------------------
164 " ----------------------------------------------------------------------------
168 " <Space> to turn off highlighting and clear any message already displayed.
169 nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
171 " <F2> to pastetoggle, to turn-off autoindent when pasting from system clipboard
172 nnoremap <F2> :set invpaste paste?<CR>
175 " <F4> to toggle NERDTreee
176 let NERDTreeShowHidden=1 " show dotfiles by default
177 noremap <F4> :NERDTreeToggle<CR>
179 " <F5> to toggle Gundo
180 nnoremap <F5> :GundoToggle<CR>
182 " <F7> to toggle spell-check
183 nnoremap <F7> :setlocal spell! spelllang=en_us spell?<CR>
184 inoremap <F7> <C-o>:setlocal spell! spelllang=en_us spell?<CR>
187 noremap <leader>o <Esc>:CommandT<CR>
188 noremap <leader>O <Esc>:CommandTFlush<CR>
189 noremap <leader>m <Esc>:CommandTBuffer<CR>
191 " make Y consistent with C (c$) and D (d$)
194 " disable default vim regex handling for searching
198 " reflow paragraph with Q in normal and visual mode
202 " movement based on display lines not physical lines (sane movement with wrap turned on)
211 inoremap <Down> <C-o>gj
212 inoremap <Up> <C-o>gk
214 " do not menu with left / right in command line
215 cnoremap <Left> <Space><BS><Left>
216 cnoremap <Right> <Space><BS><Right>
219 nnoremap <C-n> :bnext<CR>
220 nnoremap <C-p> :bprev<CR>
222 " easier split-window movement
223 nnoremap <C-h> <C-w>h
224 nnoremap <C-j> <C-w>j
225 nnoremap <C-k> <C-w>k
226 nnoremap <C-l> <C-w>l
228 " quickly edit/reload vimrc
229 nmap <silent> <leader>ev :edit $MYVIMRC<CR>
230 nmap <silent> <leader>sv :source $MYVIMRC<CR>
233 nmap <leader>u mQviwU`Q
234 nmap <leader>l mQviwu`Q
236 " upper/lower first char of word
237 nmap <leader>U mQgewvU`Q
238 nmap <leader>L mQgewvu`Q
240 " cd to the directory containing the file in the buffer
241 nmap <silent> <leader>cd :lcd %:h<CR>
243 " set text wrapping toggles
244 nmap <silent> <leader>tw :set invwrap<CR>:set wrap?<CR>
246 " find merge conflict markers
247 nmap <silent> <leader>fc <ESC>/\v^[<=>]{7}( .*\|$)<CR>
249 " toggle hlsearch with <leader>hs
250 nmap <silent> <leader>hs :set hlsearch! hlsearch?<CR>
252 " strip all trailing whitespace in file
253 function! StripWhitespace ()
256 map <leader>s :call StripWhitespace ()<CR>
258 " ----------------------------------------------------------------------------
260 " ----------------------------------------------------------------------------
262 " jump to last position of buffer when opening (but not for commit messages)
263 au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") |
264 \ exe "normal g'\"" | endif
266 " ----------------------------------------------------------------------------
268 " ----------------------------------------------------------------------------
270 if system('uname') =~ 'Darwin'
272 \ '/usr/local/bin:/usr/local/sbin:' .
274 \ '/opt/local/bin:/opt/local/sbin:' .
278 " ---------------------------------------------------------------------------
280 " ---------------------------------------------------------------------------
283 au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab
286 au Filetype gitcommit set tw=68 spell spelllang=en_us
288 au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim
289 " don't use cindent for javascript
290 au FileType javascript setlocal nocindent
291 " use Octopress syntax-highlighting for *.markdown files
292 au BufNewFile,BufRead *.markdown set filetype=octopress spell spelllang=en_us
293 " in Makefiles, use real tabs not tabs expanded to spaces
294 au FileType make setlocal noexpandtab
296 " --------------------------------------------------------------------------
298 " --------------------------------------------------------------------------
300 let g:manpageview_pgm= 'man -P "/usr/bin/less -is"'
301 let $MANPAGER = '/usr/bin/less -is'