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