comparison vim/vimrc @ 83:a54180045075

Vimrc changes: - Fixed path problems since we don't link .vim anymore. - Fixed matchpairs in PHP. - Added proper autocmd group. - Changed mappings for CtrlP. - Cleaned up code.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 22 Mar 2012 11:49:03 -0700
parents 121bef55252f
children 64c42f5c9a97 b96ff0dd0137
comparison
equal deleted inserted replaced
82:6b2c3f14a5c1 83:a54180045075
17 if exists('g:sourced_vimrc') 17 if exists('g:sourced_vimrc')
18 let g:resourcing_vimrc = 1 18 let g:resourcing_vimrc = 1
19 endif 19 endif
20 let g:sourced_vimrc = 1 20 let g:sourced_vimrc = 1
21 21
22 " Set some important system-dependent variables. 22 " Get the platform we're running on.
23 if has("win32") || has("win64") || has("dos32") 23 if has("win32") || has("win64") || has("dos32")
24 let $HOMEVIM = "vimfiles" 24 let s:vim_platform = "windows"
25 let $PLATFORM = "windows"
26 else 25 else
27 let $HOMEVIM = ".vim" 26 let s:vim_platform = "unix"
28 let $PLATFORM = "unix" 27 endif
29 endif 28
29 " Get our vim directory.
30 let s:vim_home=expand("<sfile>:h")
30 31
31 " Disable some plugins. 32 " Disable some plugins.
32 let g:pathogen_disabled = [] 33 let g:pathogen_disabled = []
33 call add(g:pathogen_disabled, 'vimroom') 34 call add(g:pathogen_disabled, 'vimroom')
34 call add(g:pathogen_disabled, 'minibufexpl') 35 call add(g:pathogen_disabled, 'minibufexpl')
111 " Don't pollute the hard-drive with *~ files. Only 112 " Don't pollute the hard-drive with *~ files. Only
112 " create them in hidden backup/temp directories while 113 " create them in hidden backup/temp directories while
113 " we edit the file, and then get rid of it. 114 " we edit the file, and then get rid of it.
114 set nobackup 115 set nobackup
115 set writebackup 116 set writebackup
116 set backupdir=~/$HOMEVIM/backup 117 execute('set backupdir='.s:vim_home.'/backup')
117 set directory=~/$HOMEVIM/temp 118 execute('set directory='.s:vim_home.'/temp')
118 119
119 " Better command-line completion, but don't show some 120 " Better command-line completion, but don't show some
120 " stuff we don't care about. 121 " stuff we don't care about.
121 set wildmenu 122 set wildmenu
122 set wildignore+=.DS_Store,Thumbs.db,*.so,*.dll,*.exe 123 set wildignore+=.DS_Store,Thumbs.db,*.so,*.dll,*.exe
158 " Nice auto-complete menu. 159 " Nice auto-complete menu.
159 set completeopt=longest,menuone,preview 160 set completeopt=longest,menuone,preview
160 161
161 " And now, for some system-dependent settings: 162 " And now, for some system-dependent settings:
162 " - font to use 163 " - font to use
163 if $PLATFORM == "windows" 164 if s:vim_platform == "windows"
164 set guifont=Consolas:h12 165 set guifont=Consolas:h12
165 else 166 else
166 set guifont=Monaco:h12 167 set guifont=Monaco:h12
167 endif 168 endif
168
169 169
170 " Syntax highlighting. 170 " Syntax highlighting.
171 syntax on 171 syntax on
172 172
173 " Change the current directory to the home directory. 173 " Change the current directory to the home directory.
212 \ 'dir': '\.git$\|\.hg$\|\.svn$', 212 \ 'dir': '\.git$\|\.hg$\|\.svn$',
213 \ 'file': '\.exe$\|\.so$\|\.dll$' 213 \ 'file': '\.exe$\|\.so$\|\.dll$'
214 \ } 214 \ }
215 215
216 " Make Ctrl-P cache stuff in our temp directory. 216 " Make Ctrl-P cache stuff in our temp directory.
217 let g:ctrlp_cache_dir = '~/'.$HOMEVIM.'/cache' 217 let g:ctrlp_cache_dir = s:vim_home.'/cache'
218 218
219 " }}} 219 " }}}
220 220
221 " File-Specific Settings {{{ 221 " File-Specific Settings {{{
222 222
223 " Nice text width for text files. 223 if has("autocmd")
224 autocmd FileType text,markdown setlocal textwidth=80 224
225 augroup VimRCFileTypeSettings
226 au!
227
228 " Nice text width for text files.
229 autocmd FileType text,markdown setlocal textwidth=80
230
231 " Who the hell changes my matchpairs?
232 autocmd FileType php setlocal matchpairs-=<:>
233
234 " File I know are markdown: personal notes & PieCrust pages.
235 autocmd BufRead,BufNewfile */Dropbox/Personal/SimpleNote/* set ft=markdown
236 autocmd BufRead,BufNewFile */_content/**/*.html set ft=markdown
237
238 augroup END
239
240 endif
225 241
226 " }}} 242 " }}}
227 243
228 " Mappings {{{ 244 " Mappings {{{
229 245
243 nnoremap <C-up> :wincmd k<cr> 259 nnoremap <C-up> :wincmd k<cr>
244 nnoremap <C-down> :wincmd j<cr> 260 nnoremap <C-down> :wincmd j<cr>
245 nnoremap <C-left> :wincmd h<cr> 261 nnoremap <C-left> :wincmd h<cr>
246 nnoremap <C-right> :wincmd l<cr> 262 nnoremap <C-right> :wincmd l<cr>
247 263
264 " Open NERDtree.
265 nnoremap <F2> :NERDTreeToggle<cr>
266
267 " Switch buffers.
268 nnoremap <F3> :execute ("buffer " . bufname("#"))<cr>
269
270 " Common typos.
271 nnoremap ; :
272
248 " Split windows 273 " Split windows
249 nnoremap <leader>s :split<cr> 274 nnoremap <leader>s :split<cr>
250 nnoremap <leader>v :vsplit<cr> 275 nnoremap <leader>v :vsplit<cr>
251 276
252 " Edit & source the VIMRC. 277 " Edit & source the VIMRC.
261 nnoremap <leader>i :set list!<cr> 286 nnoremap <leader>i :set list!<cr>
262 287
263 " Clear search matches 288 " Clear search matches
264 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr> 289 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
265 290
266 " Open NERDtree.
267 nnoremap <F2> :NERDTreeToggle<cr>
268
269 " Switch buffers.
270 nnoremap <F3> :execute ("buffer " . bufname("#"))<cr>
271
272 " Ctrl-P mappings. 291 " Ctrl-P mappings.
273 nnoremap <silent> <C-p> :CtrlP<cr> 292 nnoremap <silent> <C-p> :CtrlP<cr>
274 nnoremap <silent> <C-b> :CtrlPBuffer<cr> 293 nnoremap <silent> <C-o> :CtrlPBuffer<cr>
275 nnoremap <silent> <C-m> :CtrlPMRU<cr> 294 nnoremap <silent> <C-i> :CtrlPMRU<cr>
276 295
277 " Switch between FR and US keyboard layouts. 296 " Switch between FR and US keyboard layouts.
278 nnoremap <leader>fr :setlocal keymap=french<cr> 297 nnoremap <leader>fr :setlocal keymap=french<cr>
279 nnoremap <leader>us :setlocal keymap=<cr> 298 nnoremap <leader>us :setlocal keymap=<cr>
280 299
289 308
290 " Create folds with <space> (in visual mode) 309 " Create folds with <space> (in visual mode)
291 vnoremap <space> zf 310 vnoremap <space> zf
292 311
293 " File-type switching 312 " File-type switching
294 nnoremap <leader>ftmd :set ft=markdown<CR> 313 nnoremap <leader>ftmd :set ft=markdown<cr>
295 314
296 " }}} 315 " }}}
297 316
298 " Abbreviations {{{ 317 " Abbreviations {{{
299 318
358 let g:lawrencium_debug = 1 377 let g:lawrencium_debug = 1
359 let g:lawrencium_trace = 0 378 let g:lawrencium_trace = 0
360 379
361 " }}} 380 " }}}
362 381
363 "let mapleader="," " Use , as Leader
364 "let gmapleader=","
365 "map Y y$ " Yank to the end of the line w/ Y
366 "map <leader>nt :tabnew<CR> " New tab w/ ,nt
367 "map <leader>f :FufFile<CR> " Find files with ,f
368 "nmap <leader>w :w!<cr>
369 "map <F3> :r !pbpaste<CR>
370 "map <F4> :setlocal spell spelllang=en_gb<CR> " Turn on spellcheck with <F4>
371 "map <F5> :set nospell<CR>
372 "set pastetoggle=<F6>
373 "map <F7> :set complete+=k<CR>
374 "map <S-F7> :set complete=-k<CR>
375 "map <F8> :YRShow<CR> " Show the YankRing w/ <F8>
376 "nnoremap <F3> :GundoToggle<CR> " Show the undo tree w/ <F3>
377 "nnoremap ; :
378 "autocmd BufRead,BufNewfile ~/notes/* set filetype=markdown " All files in ~/notes are Markdown
379 "au BufWinLeave *.html,*.css mkview
380 "au BufWinEnter *.html,*.css silent loadview
381 "au FileType mail set tw=65 " Thin width when writing mail in mutt
382 "au FocusLost * :wa " Saves file when vim loses focus
383 "if has('statusline') " Status line with git repo info
384 " set statusline=%<%f\
385 " set statusline+=%w%h%m%r
386 " set statusline+=%{fugitive#statusline()}
387 " set statusline+=\ [%{&ff}/%Y]
388 " set statusline+=\ [%{getcwd()}]
389 " set statusline+=%=%-14.(Line:\ %l\ of\ %L\ [%p%%]\ -\ Col:\ %c%V%)
390 "endif
391
392 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
393 " let &guioptions = substitute(&guioptions, "t", "", "g")
394
395 " Don't use Ex mode, use Q for formatting
396 "map Q gq
397
398 " This is an alternative that also works in block mode, but the deleted
399 " text is lost and it only works for putting the current register.
400 "vnoremap p "_dp
401
402 " Switch syntax highlighting on, when the terminal has colors
403 " Also switch on highlighting the last used search pattern.
404 "if &t_Co > 2 || has("gui_running")
405 " syntax on
406 " set hlsearch
407 "endif
408
409 " Only do this part when compiled with support for autocommands.
410 "if has("autocmd")
411
412 " Enable file type detection.
413 " Use the default filetype settings, so that mail gets 'tw' set to 72,
414 " 'cindent' is on in C files, etc.
415 " Also load indent files, to automatically do language-dependent indenting.
416 " filetype plugin indent on
417
418 " Put these in an autocmd group, so that we can delete them easily.
419 " augroup vimrcEx
420 " au!
421
422 " For all text files set 'textwidth' to 78 characters.
423 " autocmd FileType text setlocal textwidth=78
424
425 " When editing a file, always jump to the last known cursor position.
426 " Don't do it when the position is invalid or when inside an event handler
427 " (happens when dropping a file on gvim).
428 " autocmd BufReadPost *
429 " \ if line("'\"") > 0 && line("'\"") <= line("$") |
430 " \ exe "normal g`\"" |
431 " \ endif
432
433 " augroup END
434
435 "else
436
437 " set autoindent " always set autoindenting on
438
439 "endif " has("autocmd")
440
441 "set fileformats=dos,unix " set fileformat to DOS by default
442