# HG changeset patch # User Ludovic Chabant # Date 1332442143 25200 # Node ID a54180045075d0c49db7a01f2bbd28e913077d66 # Parent 6b2c3f14a5c1ca77b903349a3270a623acd95ac3 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. diff -r 6b2c3f14a5c1 -r a54180045075 vim/vimrc --- 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(":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 :wincmd h nnoremap :wincmd l +" Open NERDtree. +nnoremap :NERDTreeToggle + +" Switch buffers. +nnoremap :execute ("buffer " . bufname("#")) + +" Common typos. +nnoremap ; : + " Split windows nnoremap s :split nnoremap v :vsplit @@ -263,16 +288,10 @@ " Clear search matches nnoremap :noh:call clearmatches() -" Open NERDtree. -nnoremap :NERDTreeToggle - -" Switch buffers. -nnoremap :execute ("buffer " . bufname("#")) - " Ctrl-P mappings. nnoremap :CtrlP -nnoremap :CtrlPBuffer -nnoremap :CtrlPMRU +nnoremap :CtrlPBuffer +nnoremap :CtrlPMRU " Switch between FR and US keyboard layouts. nnoremap fr :setlocal keymap=french @@ -291,7 +310,7 @@ vnoremap zf " File-type switching -nnoremap ftmd :set ft=markdown +nnoremap ftmd :set ft=markdown " }}} @@ -360,83 +379,3 @@ " }}} -"let mapleader="," " Use , as Leader -"let gmapleader="," -"map Y y$ " Yank to the end of the line w/ Y -"map nt :tabnew " New tab w/ ,nt -"map f :FufFile " Find files with ,f -"nmap w :w! -"map :r !pbpaste -"map :setlocal spell spelllang=en_gb " Turn on spellcheck with -"map :set nospell -"set pastetoggle= -"map :set complete+=k -"map :set complete=-k -"map :YRShow " Show the YankRing w/ -"nnoremap :GundoToggle " Show the undo tree w/ -"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 -