diff 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
line wrap: on
line diff
--- a/vim/vimrc	Thu Mar 22 11:11:16 2012 -0700
+++ b/vim/vimrc	Thu Mar 22 11:49:03 2012 -0700
@@ -19,15 +19,16 @@
 endif
 let g:sourced_vimrc = 1
 
-" Set some important system-dependent variables.
+" Get the platform we're running on.
 if has("win32") || has("win64") || has("dos32")
-    let $HOMEVIM = "vimfiles"
-    let $PLATFORM = "windows"
+    let s:vim_platform = "windows"
 else
-    let $HOMEVIM = ".vim"
-    let $PLATFORM = "unix"
+    let s:vim_platform = "unix"
 endif
 
+" Get our vim directory. 
+let s:vim_home=expand("<sfile>:h")
+
 " Disable some plugins.
 let g:pathogen_disabled = []
 call add(g:pathogen_disabled, 'vimroom')
@@ -113,8 +114,8 @@
 " we edit the file, and then get rid of it.
 set nobackup
 set writebackup
-set backupdir=~/$HOMEVIM/backup
-set directory=~/$HOMEVIM/temp
+execute('set backupdir='.s:vim_home.'/backup')
+execute('set directory='.s:vim_home.'/temp')
 
 " Better command-line completion, but don't show some
 " stuff we don't care about.
@@ -160,13 +161,12 @@
 
 " And now, for some system-dependent settings:
 " - font to use
-if $PLATFORM == "windows"
+if s:vim_platform == "windows"
     set guifont=Consolas:h12
 else
     set guifont=Monaco:h12
 endif
 
-
 " Syntax highlighting.
 syntax on
 
@@ -214,14 +214,30 @@
   \ }
 
 " Make Ctrl-P cache stuff in our temp directory.
-let g:ctrlp_cache_dir = '~/'.$HOMEVIM.'/cache'
+let g:ctrlp_cache_dir = s:vim_home.'/cache'
 
 " }}}
 
 " File-Specific Settings {{{
 
-" Nice text width for text files.
-autocmd FileType text,markdown setlocal textwidth=80
+if has("autocmd")
+
+    augroup VimRCFileTypeSettings
+        au!
+    
+        " Nice text width for text files.
+        autocmd FileType text,markdown setlocal textwidth=80
+
+        " Who the hell changes my matchpairs?
+        autocmd FileType php setlocal matchpairs-=<:>
+
+        " File I know are markdown: personal notes & PieCrust pages.
+        autocmd BufRead,BufNewfile */Dropbox/Personal/SimpleNote/* set ft=markdown
+        autocmd BufRead,BufNewFile */_content/**/*.html set ft=markdown
+
+    augroup END
+
+endif
 
 " }}}
 
@@ -245,6 +261,15 @@
 nnoremap <C-left> :wincmd h<cr>
 nnoremap <C-right> :wincmd l<cr>
 
+" Open NERDtree.
+nnoremap <F2> :NERDTreeToggle<cr>
+
+" Switch buffers.
+nnoremap <F3> :execute ("buffer " . bufname("#"))<cr>
+
+" Common typos.
+nnoremap ; :
+
 " Split windows
 nnoremap <leader>s :split<cr>
 nnoremap <leader>v :vsplit<cr>
@@ -263,16 +288,10 @@
 " Clear search matches
 nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
 
-" Open NERDtree.
-nnoremap <F2> :NERDTreeToggle<cr>
-
-" Switch buffers.
-nnoremap <F3> :execute ("buffer " . bufname("#"))<cr>
-
 " Ctrl-P mappings.
 nnoremap <silent> <C-p> :CtrlP<cr>
-nnoremap <silent> <C-b> :CtrlPBuffer<cr>
-nnoremap <silent> <C-m> :CtrlPMRU<cr>
+nnoremap <silent> <C-o> :CtrlPBuffer<cr>
+nnoremap <silent> <C-i> :CtrlPMRU<cr>
 
 " Switch between FR and US keyboard layouts.
 nnoremap <leader>fr :setlocal keymap=french<cr>
@@ -291,7 +310,7 @@
 vnoremap <space> zf
 
 " File-type switching
-nnoremap <leader>ftmd :set ft=markdown<CR>
+nnoremap <leader>ftmd :set ft=markdown<cr>
 
 " }}}
 
@@ -360,83 +379,3 @@
 
 " }}}
 
-"let mapleader=","                                               " Use , as Leader
-"let gmapleader=","
-"map Y y$                                                        " Yank to the end of the line w/ Y
-"map <leader>nt :tabnew<CR>                                      " New tab w/ ,nt
-"map <leader>f :FufFile<CR>                                      " Find files with ,f
-"nmap <leader>w :w!<cr>
-"map <F3> :r !pbpaste<CR>
-"map <F4> :setlocal spell spelllang=en_gb<CR>                    " Turn on spellcheck with <F4>
-"map <F5> :set nospell<CR>
-"set pastetoggle=<F6>
-"map <F7> :set complete+=k<CR>
-"map <S-F7> :set complete=-k<CR>                                 
-"map <F8> :YRShow<CR>                                            " Show the YankRing w/ <F8>
-"nnoremap <F3> :GundoToggle<CR>                                  " Show the undo tree w/ <F3>
-"nnoremap ; :
-"autocmd BufRead,BufNewfile ~/notes/* set filetype=markdown      " All files in ~/notes are Markdown
-"au BufWinLeave *.html,*.css mkview	
-"au BufWinEnter *.html,*.css silent loadview	
-"au FileType mail set tw=65                                      " Thin width when writing mail in mutt 
-"au FocusLost * :wa                                              " Saves file when vim loses focus
-"if has('statusline')                                            " Status line with git repo info
-"  set statusline=%<%f\ 
-"  set statusline+=%w%h%m%r 
-"  set statusline+=%{fugitive#statusline()}
-"  set statusline+=\ [%{&ff}/%Y]  
-"  set statusline+=\ [%{getcwd()}]
-"  set statusline+=%=%-14.(Line:\ %l\ of\ %L\ [%p%%]\ -\ Col:\ %c%V%)
-"endif
-
-" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
-" let &guioptions = substitute(&guioptions, "t", "", "g")
-
-" Don't use Ex mode, use Q for formatting
-"map Q gq
-
-" This is an alternative that also works in block mode, but the deleted
-" text is lost and it only works for putting the current register.
-"vnoremap p "_dp
-
-" Switch syntax highlighting on, when the terminal has colors
-" Also switch on highlighting the last used search pattern.
-"if &t_Co > 2 || has("gui_running")
-"  syntax on
-"  set hlsearch
-"endif
-
-" Only do this part when compiled with support for autocommands.
-"if has("autocmd")
-
-  " Enable file type detection.
-  " Use the default filetype settings, so that mail gets 'tw' set to 72,
-  " 'cindent' is on in C files, etc.
-  " Also load indent files, to automatically do language-dependent indenting.
-"  filetype plugin indent on
-
-  " Put these in an autocmd group, so that we can delete them easily.
-"  augroup vimrcEx
-"  au!
-
-  " For all text files set 'textwidth' to 78 characters.
-"  autocmd FileType text setlocal textwidth=78
-
-  " When editing a file, always jump to the last known cursor position.
-  " Don't do it when the position is invalid or when inside an event handler
-  " (happens when dropping a file on gvim).
-"  autocmd BufReadPost *
-"    \ if line("'\"") > 0 && line("'\"") <= line("$") |
-"    \   exe "normal g`\"" |
-"    \ endif
-
-"  augroup END
-
-"else
-
-"  set autoindent		" always set autoindenting on
-
-"endif " has("autocmd")
-
-"set fileformats=dos,unix	" set fileformat to DOS by default
-