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