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