]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - .vimrc
.vimrc: background=dark
[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 filetype plugin indent on " load filetype plugin
10 set iskeyword+=_,$,@,%,#,- " none word dividers
11 set viminfo='1000,f1,:100,@100,/20
12 set modeline " make sure modeline support is enabled
13 set autoread " reload files (no local changes only)
14 call pathogen#infect() " enable pathogen (plugin bundles)
15
16 " ---------------------------------------------------------------------------
17 " Colors / Theme
18 " ---------------------------------------------------------------------------
19
20 if &t_Co > 2 || has("gui_running")
21 if has("terminfo")
22 set t_Co=16
23 set t_AB=\e[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
24 set t_AF=\e[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
25 else
26 set t_Co=16
27 set t_Sf=\e[3%dm
28 set t_Sb=\e[4%dm
29 endif
30
31 syntax on " syntax highligting
32 set hlsearch " highlight all search matches
33 " Press Space to turn off highlighting and clear any message already displayed.
34 :nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
35
36 " Define to-do colors
37 if !exists("autocmd_colorscheme_loaded")
38 let autocmd_colorscheme_loaded = 1
39 autocmd ColorScheme * highlight TodoRed ctermbg=LightRed guibg=#E01B1B ctermfg=White guifg=#002b37
40 endif
41
42 " Solarized color-scheme
43 let g:solarized_termtrans=1 " Always use terminal's default bg color
44 set background=dark
45 colorscheme solarized
46
47 " Auto-highlight TODO's
48 if has("autocmd")
49 if v:version > 701
50 autocmd Syntax * call matchadd('TodoRed', '\W\zs\(TODO\)')
51 endif
52 endif
53 endif
54
55 " ---------------------------------------------------------------------------
56 " Highlight
57 " ---------------------------------------------------------------------------
58
59 highlight Comment ctermfg=DarkGrey guifg=#444444
60 highlight StatusLineNC ctermfg=Black ctermbg=DarkGrey cterm=bold
61 highlight StatusLine ctermbg=Black ctermfg=LightGrey
62
63 " ----------------------------------------------------------------------------
64 " Highlight Trailing Whitespace
65 " ----------------------------------------------------------------------------
66
67 set list listchars=trail:.,tab:>.
68 highlight SpecialKey ctermfg=DarkGray ctermbg=Black
69
70 " ----------------------------------------------------------------------------
71 " Backups
72 " ----------------------------------------------------------------------------
73
74 set nobackup " do not keep backups after close
75 set nowritebackup " do not keep a backup while working
76 set noswapfile " don't keep swp files either
77 set backupdir=$HOME/.vim/backup " store backups under ~/.vim/backup
78 set backupcopy=yes " keep attributes of original file
79 set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
80 set directory=~/.vim/swap,~/tmp,. " keep swp files under ~/.vim/swap
81
82 " ----------------------------------------------------------------------------
83 " UI
84 " ----------------------------------------------------------------------------
85
86 set ruler " show the cursor position all the time
87 set noshowcmd " don't display incomplete commands
88 set nolazyredraw " turn off lazy redraw
89 "set number " line numbers
90 set wildmenu " turn on wild menu
91 set wildmode=list:longest,full
92 set ch=2 " command line height
93 set backspace=2 " allow backspacing over everything in insert mode
94 set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
95 set shortmess=filtIoOA " shorten messages
96 set report=0 " tell us about changes
97 set nostartofline " don't jump to the start of line when scrolling
98
99 " ----------------------------------------------------------------------------
100 " Visual Cues
101 " ----------------------------------------------------------------------------
102
103 set showmatch " brackets/braces that is
104 set mat=5 " duration to show matching brace (1/10 sec)
105 set incsearch " do incremental searching
106 set laststatus=2 " always show the status line
107 set ignorecase " ignore case when searching
108 set smartcase " case-sensitive if search contains an uppercase character
109 set visualbell " shut the heck up
110
111 " ----------------------------------------------------------------------------
112 " Text Formatting
113 " ----------------------------------------------------------------------------
114
115 set autoindent " automatic indent new lines
116 set smartindent " be smart about it
117 "set nowrap " do not wrap lines
118 set softtabstop=2 " yep, two
119 set shiftwidth=2 " ..
120 set tabstop=4
121 set expandtab " expand tabs to spaces
122 set nosmarttab " screw tabs
123 set formatoptions+=n " support for numbered/bullet lists
124 set textwidth=80 " wrap at 80 chars by default
125 set virtualedit=block " allow virtual edit in visual block ..
126
127 " ----------------------------------------------------------------------------
128 " Tabs
129 " ----------------------------------------------------------------------------
130
131 if version >= 700
132 set tabpagemax=50 " open 50 tabs max
133 endif
134
135 " ----------------------------------------------------------------------------
136 " Mappings
137 " ----------------------------------------------------------------------------
138
139 " <F2> to pastetoggle, to turn-off autoindent when pasting from system clipboard
140 nnoremap <F2> :set invpaste paste?<CR>
141 set pastetoggle=<F2>
142 set showmode
143
144 "" <F8>/<Shift>-<F8> to navigation between buffers
145 if version >= 700
146 set switchbuf=usetab
147 nnoremap <F8> :sbnext<CR>
148 nnoremap <S-F8> :sbprevious<CR>
149 endif
150
151 "" quickfix mappings
152 "map <F7> :cn<CR>
153 "map <S-F7> :cp<CR>
154 "map <A-F7> :copen<CR>
155
156 "" emacs movement keybindings in insert mode
157 "imap <C-a> <C-o>0
158 "imap <C-e> <C-o>$
159 "map <C-e> $
160 "map <C-a> 0
161
162 " reflow paragraph with Q in normal and visual mode
163 nnoremap Q gqap
164 vnoremap Q gq
165
166 "" sane movement with wrap turned on
167 "nnoremap j gj
168 "nnoremap k gk
169 "vnoremap j gj
170 "vnoremap k gk
171 "nnoremap <Down> gj
172 "nnoremap <Up> gk
173 "vnoremap <Down> gj
174 "vnoremap <Up> gk
175 "inoremap <Down> <C-o>gj
176 "inoremap <Up> <C-o>gk
177
178 "" do not menu with left / right in command line
179 "cnoremap <Left> <Space><BS><Left>
180 "cnoremap <Right> <Space><BS><Right>
181
182 " ----------------------------------------------------------------------------
183 " Auto Commands
184 " ----------------------------------------------------------------------------
185
186 " jump to last position of buffer when opening
187 au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
188 \ exe "normal g'\"" | endif
189
190 " don't use cindent for javascript
191 autocmd FileType javascript setlocal nocindent
192
193 " ----------------------------------------------------------------------------
194 " LookupFile
195 " ----------------------------------------------------------------------------
196
197 "let g:LookupFile_TagExpr = '".ftags"'
198 "let g:LookupFile_MinPatLength = 2
199 "let g:LookupFile_ShowFiller = 0 " fix menu flashiness
200 "let g:LookupFile_PreservePatternHistory = 1 " preserve sorted history?
201 "let g:LookupFile_PreserveLastPattern = 0 " start with last pattern?
202 "
203 "nmap <unique> <silent> <D-f> <Plug>LookupFile
204 "imap <unique> <silent> <D-f> <C-O><Plug>LookupFile
205
206 " ----------------------------------------------------------------------------
207 " PATH on MacOS X
208 " ----------------------------------------------------------------------------
209
210 if system('uname') =~ 'Darwin'
211 let $PATH = $HOME .
212 \ '/usr/local/bin:/usr/local/sbin:' .
213 \ '/usr/pkg/bin:' .
214 \ '/opt/local/bin:/opt/local/sbin:' .
215 \ $PATH
216 endif
217
218 " ---------------------------------------------------------------------------
219 " sh config
220 " ---------------------------------------------------------------------------
221
222 au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab
223 let g:is_bash = 1
224
225 " ---------------------------------------------------------------------------
226 " Misc mappings
227 " ---------------------------------------------------------------------------
228
229 "map ,f :tabnew <cfile><CR>
230 "map ,d :e %:h/<CR>
231 "map ,dt :tabnew %:h/<CR>
232
233 "" I use these commands in my TODO file
234 "map ,a o<ESC>:r!date +'\%A, \%B \%d, \%Y'<CR>:r!date +'\%A, \%B \%d, \%Y' \| sed 's/./-/g'<CR>A<CR><ESC>
235 "map ,o o[ ]
236 "map ,O O[ ]
237 "map ,x :s/^\[ \]/[x]/<CR>
238 "map ,X :s/^\[x\]/[ ]/<CR>
239
240 " ---------------------------------------------------------------------------
241 " Strip all trailing whitespace in file
242 " ---------------------------------------------------------------------------
243
244 function! StripWhitespace ()
245 exec ':%s/ \+$//gc'
246 endfunction
247 map ,s :call StripWhitespace ()<CR>
248
249 " ---------------------------------------------------------------------------
250 " File Types
251 " ---------------------------------------------------------------------------
252
253 au Filetype gitcommit set tw=68 spell
254 "au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim
255
256 " --------------------------------------------------------------------------
257 " ManPageView
258 " --------------------------------------------------------------------------
259
260 let g:manpageview_pgm= 'man -P "/usr/bin/less -is"'
261 let $MANPAGER = '/usr/bin/less -is'
262