]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - .vimrc
.vimrc: Add wildignore exclusions
[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 StatusLineNC ctermfg=Black ctermbg=DarkGrey cterm=bold
67 highlight StatusLine ctermbg=Black ctermfg=LightGrey
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 backupdir=$HOME/.vim/backup " store backups under ~/.vim/backup
83 set backupcopy=yes " keep attributes of original file
84 set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
85 set directory=.,~/tmp,~/.vim/swap " swap file directory-order
86
87 " ----------------------------------------------------------------------------
88 " UI
89 " ----------------------------------------------------------------------------
90
91 set ruler " show the cursor position all the time
92 set showcmd " display incomplete commands
93 set nolazyredraw " turn off lazy redraw
94 set hidden " keep buffers loaded when hidden
95 set showmode " show mode at bottom of screen
96 set wildmenu " turn on wild menu
97 set wildmode=list:longest,full
98 set cmdheight=2 " command line height
99 set backspace=2 " allow backspacing over everything in insert mode
100 set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
101 set shortmess=filtIoO " shorten messages
102 set report=0 " tell us about changes
103 set nostartofline " don't jump to the start of line when scrolling
104 set scrolloff=4 " vertcal padding
105 set sidescroll=40 " side-scrolling increment (for nowrap mode)
106
107 " ----------------------------------------------------------------------------
108 " Visual Cues
109 " ----------------------------------------------------------------------------
110
111 set showmatch " brackets/braces that is
112 set matchtime=5 " duration to show matching brace (1/10 sec)
113 set incsearch " do incremental searching
114 set laststatus=2 " always show the status line
115 set ignorecase " ignore case when searching
116 set smartcase " case-sensitive if search contains an uppercase character
117 set visualbell " shut the heck up
118
119 " ----------------------------------------------------------------------------
120 " Text Formatting
121 " ----------------------------------------------------------------------------
122
123 set autoindent " automatic indent new lines
124 set smartindent " be smart about it
125 set nowrap " do not wrap lines
126 set softtabstop=2 " yep, two
127 set shiftwidth=2 " ..
128 set tabstop=4
129 set expandtab " expand tabs to spaces
130 set nosmarttab " screw tabs
131 set formatoptions+=n " support for numbered/bullet lists
132 "set textwidth=110 " wrap at 110 chars by default
133 set virtualedit=block " allow virtual edit in visual block ..
134
135 " ----------------------------------------------------------------------------
136 " Filename exclusions
137 " ----------------------------------------------------------------------------
138
139 set wildignore+=.hg,.git,.svn " version control directories
140 set wildignore+=*.jpg,*.jpeg,*.bmp,*.gif,*.png " image files
141 set wildignore+=*.o,*.obj,*.exe,*.dll " compiled object files
142 set wildignore+=*.pyc " Python byte code
143 set wildignore+=*.sw? " Vim swap files
144 set wildignore+=.DS_Store " OSX junk
145
146 " ----------------------------------------------------------------------------
147 " Tabs
148 " ----------------------------------------------------------------------------
149
150 if version >= 700
151 set tabpagemax=50 " open 50 tabs max
152 endif
153
154 " ----------------------------------------------------------------------------
155 " Mappings
156 " ----------------------------------------------------------------------------
157
158 let mapleader = ","
159
160 " <F2> to pastetoggle, to turn-off autoindent when pasting from system clipboard
161 nnoremap <F2> :set invpaste paste?<CR>
162 set pastetoggle=<F2>
163
164 "" <F8>/<Shift>-<F8> to navigation between buffers
165 if version >= 700
166 set switchbuf=usetab
167 nnoremap <F8> :sbnext<CR>
168 nnoremap <S-F8> :sbprevious<CR>
169 endif
170
171 " disable default vim regex handling for searching
172 nnoremap / /\v
173 vnoremap / /\v
174
175 " reflow paragraph with Q in normal and visual mode
176 nnoremap Q gqap
177 vnoremap Q gq
178
179 " sane movement with wrap turned on
180 nnoremap j gj
181 nnoremap k gk
182 vnoremap j gj
183 vnoremap k gk
184 nnoremap <Down> gj
185 nnoremap <Up> gk
186 vnoremap <Down> gj
187 vnoremap <Up> gk
188 inoremap <Down> <C-o>gj
189 inoremap <Up> <C-o>gk
190
191 " do not menu with left / right in command line
192 cnoremap <Left> <Space><BS><Left>
193 cnoremap <Right> <Space><BS><Right>
194
195 " easier split-window movement
196 nnoremap <C-h> <C-w>h
197 nnoremap <C-j> <C-w>j
198 nnoremap <C-k> <C-w>k
199 nnoremap <C-l> <C-w>l
200
201 " quickly edit/reload vimrc
202 nmap <silent> <leader>ev :edit $MYVIMRC<CR>
203 nmap <silent> <leader>sv :source $MYVIMRC<CR>
204
205 " ----------------------------------------------------------------------------
206 " Auto Commands
207 " ----------------------------------------------------------------------------
208
209 " jump to last position of buffer when opening
210 au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
211 \ exe "normal g'\"" | endif
212
213 " ----------------------------------------------------------------------------
214 " PATH on MacOS X
215 " ----------------------------------------------------------------------------
216
217 if system('uname') =~ 'Darwin'
218 let $PATH = $HOME .
219 \ '/usr/local/bin:/usr/local/sbin:' .
220 \ '/usr/pkg/bin:' .
221 \ '/opt/local/bin:/opt/local/sbin:' .
222 \ $PATH
223 endif
224
225 " ---------------------------------------------------------------------------
226 " sh config
227 " ---------------------------------------------------------------------------
228
229 au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab
230 let g:is_bash = 1
231
232 " ---------------------------------------------------------------------------
233 " Strip all trailing whitespace in file
234 " ---------------------------------------------------------------------------
235
236 function! StripWhitespace ()
237 exec ':%s/ \+$//gc'
238 endfunction
239 map <leader>s :call StripWhitespace ()<CR>
240
241 " ---------------------------------------------------------------------------
242 " File Types
243 " ---------------------------------------------------------------------------
244
245 au Filetype gitcommit set tw=68 spell
246 au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim
247 " don't use cindent for javascript
248 au FileType javascript setlocal nocindent
249 " Use Octopress syntax-highlighting for *.markdown files
250 au BufNewFile,BufRead *.markdown set filetype=octopress
251
252 " --------------------------------------------------------------------------
253 " ManPageView
254 " --------------------------------------------------------------------------
255
256 let g:manpageview_pgm= 'man -P "/usr/bin/less -is"'
257 let $MANPAGER = '/usr/bin/less -is'
258
259 " --------------------------------------------------------------------------
260 " Bundle Config
261 " --------------------------------------------------------------------------
262
263 "" Gundo
264 nnoremap <F5> :GundoToggle<CR>
265