]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - .vimrc
.vimrc: Lower-contrast "highlight StatusLine"
[dotfiles.git] / .vimrc
1 " ---------------------------------------------------------------------------
2 " General
3 " ---------------------------------------------------------------------------
4
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)
13
14 " ---------------------------------------------------------------------------
15 " Pathogen Init (Bundles)
16 " ---------------------------------------------------------------------------
17 filetype off
18 call pathogen#infect()
19 call pathogen#helptags()
20 filetype plugin indent on " enable plugins, detection and indenting in one step
21
22 " ---------------------------------------------------------------------------
23 " Colors / Theme
24 " ---------------------------------------------------------------------------
25
26 if &t_Co > 2 || has("gui_running")
27 if has("terminfo")
28 set t_Co=16
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
31 else
32 set t_Co=16
33 set t_Sf=\e[3%dm
34 set t_Sb=\e[4%dm
35 endif
36
37 set background=dark " dark background
38 syntax enable " syntax highligting
39 set hlsearch " highlight all search matches
40 " Press <Space> to turn off highlighting and clear any message already displayed.
41 nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
42
43 " Define to-do color(s)
44 if !exists("autocmd_colorscheme_loaded")
45 let autocmd_colorscheme_loaded = 1
46 autocmd ColorScheme * highlight TodoRed ctermbg=LightRed guibg=#E01B1B ctermfg=White guifg=#002b37
47 endif
48
49 " Solarized color-scheme
50 let g:solarized_termtrans=1 " Always use terminal's default bg color
51 colorscheme solarized
52
53 " Auto-highlight TODO's
54 if has("autocmd")
55 if v:version > 701
56 autocmd Syntax * call matchadd('TodoRed', '\W\zs\(TODO\)')
57 endif
58 endif
59 endif
60
61 " ---------------------------------------------------------------------------
62 " Highlight
63 " ---------------------------------------------------------------------------
64
65 highlight Comment ctermfg=DarkGrey guifg=#444444
66 highlight StatusLine ctermfg=DarkGrey ctermbg=Grey cterm=reverse guifg=#444444 guibg=#aaaaaa gui=reverse
67 highlight StatusLineNC ctermfg=DarkGrey ctermbg=DarkGrey cterm=reverse guifg=#444444 guibg=#666666 gui=reverse
68
69 " ----------------------------------------------------------------------------
70 " Highlight Trailing Whitespace
71 " ----------------------------------------------------------------------------
72
73 set list listchars=trail:.,tab:>.
74 highlight SpecialKey ctermfg=DarkGray ctermbg=Black
75
76 " ----------------------------------------------------------------------------
77 " Backups
78 " ----------------------------------------------------------------------------
79
80 set nobackup " do not keep backups after close
81 set nowritebackup " do not keep a backup while working
82 set backupcopy=yes " keep attributes of original file
83 set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
84 set directory=.,~/tmp,~/.vim/swap " swap file directory-order
85
86 " ----------------------------------------------------------------------------
87 " UI
88 " ----------------------------------------------------------------------------
89
90 set ruler " show the cursor position all the time
91 set showcmd " display incomplete commands
92 set nolazyredraw " turn off lazy redraw
93 set hidden " keep buffers loaded when hidden
94 set showmode " show mode at bottom of screen
95 set wildmenu " turn on wild menu
96 set wildmode=list:longest,full
97 set cmdheight=2 " command line height
98 set backspace=2 " allow backspacing over everything in insert mode
99 set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
100 set shortmess=filtIoO " shorten messages
101 set report=0 " tell us about changes
102 set nostartofline " don't jump to the start of line when scrolling
103 set scrolloff=4 " vertcal padding
104 set sidescroll=40 " side-scrolling increment (for nowrap mode)
105
106 " ----------------------------------------------------------------------------
107 " Visual Cues
108 " ----------------------------------------------------------------------------
109
110 set showmatch " brackets/braces that is
111 set matchtime=5 " duration to show matching brace (1/10 sec)
112 set incsearch " do incremental searching
113 set laststatus=2 " always show the status line
114 set ignorecase " ignore case when searching
115 set smartcase " case-sensitive if search contains an uppercase character
116 set visualbell " shut the heck up
117
118 " ----------------------------------------------------------------------------
119 " Status Line
120 " ----------------------------------------------------------------------------
121
122 set statusline=\ %n\ %<%f " buffer #, filename
123 set statusline+=\ %h%m%r " file-state flags
124 set statusline+=%= " left-right divider
125 set statusline+=[%{strlen(&fenc)?&fenc:&enc},%{&ff}]%y " file-encoding, format, type
126 set statusline+=\ %11.(\(%b\ 0x%B)%) " selected char ASCII dec+hex
127 set statusline+=\ \ %12.(%c,%l/%L%)\ \ %-4P " cursor position, viewport percentage
128
129 " ----------------------------------------------------------------------------
130 " Text Formatting
131 " ----------------------------------------------------------------------------
132
133 set autoindent " automatic indent new lines
134 set smartindent " be smart about it
135 set nowrap " do not wrap lines
136 set softtabstop=2 " yep, two
137 set shiftwidth=2 " ..
138 set tabstop=4
139 set expandtab " expand tabs to spaces
140 set nosmarttab " screw tabs
141 set formatoptions+=n " support for numbered/bullet lists
142 set textwidth=0 " no line-wrapping by default
143 set virtualedit=block " allow virtual edit in visual block ..
144
145 " ----------------------------------------------------------------------------
146 " Filename exclusions
147 " ----------------------------------------------------------------------------
148
149 set wildignore+=.hg,.git,.svn " version control directories
150 set wildignore+=*.jpg,*.jpeg,*.bmp,*.gif,*.png " image files
151 set wildignore+=*.o,*.obj,*.exe,*.dll " compiled object files
152 set wildignore+=*.pyc " Python byte code
153 set wildignore+=*.sw? " Vim swap files
154 set wildignore+=.DS_Store " OSX junk
155
156 " ----------------------------------------------------------------------------
157 " Tabs
158 " ----------------------------------------------------------------------------
159
160 if version >= 700
161 set tabpagemax=50 " open 50 tabs max
162 endif
163
164 " ----------------------------------------------------------------------------
165 " Mappings
166 " ----------------------------------------------------------------------------
167
168 let mapleader = ","
169
170 " <F2> to pastetoggle, to turn-off autoindent when pasting from system clipboard
171 nnoremap <F2> :set invpaste paste?<CR>
172 set pastetoggle=<F2>
173
174 " disable default vim regex handling for searching
175 nnoremap / /\v
176 vnoremap / /\v
177
178 " reflow paragraph with Q in normal and visual mode
179 nnoremap Q gqap
180 vnoremap Q gq
181
182 " movement based on display lines not physical lines (sane movement with wrap turned on)
183 nnoremap j gj
184 nnoremap k gk
185 vnoremap j gj
186 vnoremap k gk
187 nnoremap <Down> gj
188 nnoremap <Up> gk
189 vnoremap <Down> gj
190 vnoremap <Up> gk
191 inoremap <Down> <C-o>gj
192 inoremap <Up> <C-o>gk
193
194 " do not menu with left / right in command line
195 cnoremap <Left> <Space><BS><Left>
196 cnoremap <Right> <Space><BS><Right>
197
198 " buffer navigation
199 nnoremap <C-n> :bnext<CR>
200 nnoremap <C-p> :bprev<CR>
201
202 " easier split-window movement
203 nnoremap <C-h> <C-w>h
204 nnoremap <C-j> <C-w>j
205 nnoremap <C-k> <C-w>k
206 nnoremap <C-l> <C-w>l
207
208 " quickly edit/reload vimrc
209 nmap <silent> <leader>ev :edit $MYVIMRC<CR>
210 nmap <silent> <leader>sv :source $MYVIMRC<CR>
211
212 " upper/lower word
213 nmap <leader>u mQviwU`Q
214 nmap <leader>l mQviwu`Q
215
216 " upper/lower first char of word
217 nmap <leader>U mQgewvU`Q
218 nmap <leader>L mQgewvu`Q
219
220 " cd to the directory containing the file in the buffer
221 nmap <silent> <leader>cd :lcd %:h<CR>
222
223 " set text wrapping toggles
224 nmap <silent> <leader>tw :set invwrap<CR>:set wrap?<CR>
225
226 " find merge conflict markers
227 nmap <silent> <leader>fc <ESC>/\v^[<=>]{7}( .*\|$)<CR>
228
229 " toggle hlsearch with <leader>hs
230 nmap <silent> <leader>hs :set hlsearch! hlsearch?<CR>
231
232 " strip all trailing whitespace in file
233 function! StripWhitespace ()
234 exec ':%s/ \+$//gc'
235 endfunction
236 map <leader>s :call StripWhitespace ()<CR>
237
238 " ----------------------------------------------------------------------------
239 " Auto Commands
240 " ----------------------------------------------------------------------------
241
242 " jump to last position of buffer when opening (but not for commit messages)
243 au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") |
244 \ exe "normal g'\"" | endif
245
246 " ----------------------------------------------------------------------------
247 " PATH on MacOS X
248 " ----------------------------------------------------------------------------
249
250 if system('uname') =~ 'Darwin'
251 let $PATH = $HOME .
252 \ '/usr/local/bin:/usr/local/sbin:' .
253 \ '/usr/pkg/bin:' .
254 \ '/opt/local/bin:/opt/local/sbin:' .
255 \ $PATH
256 endif
257
258 " ---------------------------------------------------------------------------
259 " File Types
260 " ---------------------------------------------------------------------------
261
262 " sh config
263 au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab
264 let g:is_bash = 1
265 " git commit message
266 au Filetype gitcommit set tw=68 spell
267 " html variants
268 au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim
269 " don't use cindent for javascript
270 au FileType javascript setlocal nocindent
271 " use Octopress syntax-highlighting for *.markdown files
272 au BufNewFile,BufRead *.markdown set filetype=octopress
273 " in Makefiles, use real tabs not tabs expanded to spaces
274 au FileType make setlocal noexpandtab
275
276 " --------------------------------------------------------------------------
277 " ManPageView
278 " --------------------------------------------------------------------------
279
280 let g:manpageview_pgm= 'man -P "/usr/bin/less -is"'
281 let $MANPAGER = '/usr/bin/less -is'
282
283 " --------------------------------------------------------------------------
284 " Bundle Config
285 " --------------------------------------------------------------------------
286
287 "" Gundo
288 nnoremap <F5> :GundoToggle<CR>
289
290 "" Command-T
291 noremap <leader>o <Esc>:CommandT<CR>
292 noremap <leader>O <Esc>:CommandTFlush<CR>
293 noremap <leader>m <Esc>:CommandTBuffer<CR>
294