Vim logo
" Auré
" Mon .vimrc a moi qui tue ! (faudrait que je le range un jour ça c'est un
" peu le bordel dedans a force faire des copier/coller d'un peu partout.
" Plein de trucs importés de partout. Par miracle ça marche ensemble :)
" Aide au code (couleurs, compte les parenthèses, indentation multiple,...)
" Formatage de réponse aux mails/news.
" Correction orthographique.
" Racourics qui vont bien de super fegnasse.

" syntax hilighting and file detection (new vim6 plugins)
if has("syntax") && &t_Co > 2
  syntax on
endif

if has("autocmd")
 filetype plugin indent on
endif " has ("autocmd")

" don't don't out in insert mode
set noinsertmode
" allow us to backspace before an insert
set backspace=2
" tabs are to be set at 4 spaces
set tabstop=4
" show the ruler for editing
set ruler
" turn off the mouse in the xterm
set mouse=a
" show the command in the status line
set showcmd
" always have a status line
set laststatus=2
" Highlighting Matches
set hlsearch

" Virginie Vacca
set autoread        " répercute dynamiquement les modifs (vim5)
set incsearch       " Incremental search (comme emacs :)
set lazyredraw      " redraw screen while executing Cmds
set nobackup        " Don't keep a backup file
set nocompatible    " Use Vim defaults (much better!)
set path=.,~/Documents,/var/www/,$VIMRUNTIME/syntax/
set whichwrap=<,>,[,]   " Allow cursor keys to wrap around lines.
set viminfo=%,'50,\"100,:100,n~/.vim/.viminfo
" Be nice and quiet
set noerrorbells
set visualbell
set t_vb=
" Merci Virginie !

set title
set showmode
"set showmatch " matching bracket
" but not all the messages
set shortmess=atTI
set ttyscroll=0
" Useful for CTRL-] stuff.
"set   iskeyword=@,48-57,_,192-255,-,.

"     comments default: sr:/*,mb:*,el:*/,://,b:#,:%,:XCOMM,n:>,fb:-
"set   comments=b:#,:%,fb:-,n:>,n:),sr:/*,mb:*,el:*/,n:###,n:\"
set joinspaces

" Email/News (mega bordel mais ça marche)
" ==========
"
" Clear Empty Lines
map ,cel :%s/^\s\+$//e^M
map ,cqoq :%s/^>\s\+/> /e^M

" remove all > On blah... stuff left behind in quoted text - huggie
"nmap ,cqmh :g/^\([>*] \)\+On.*wrote:$/d<CR>
" vim doesn't yet do matching on multilines AFAIK.
"map ,db :1,20s/\(^On.*wrote:$\)\n\+/\1/^M
" Clear blank lines after my On foo wrote: 
map ,db /^>.*On.*wrote:$/e^Mjmt:.,.s/^$//gec^Mq/^.\+$^Mkmb`td'b^M

" Kill empty quoted lines
nmap ,ceql :g/^\(> \)\{2,}\s*$/d<CR>^M
nmap ,cqel :%s/^> \s*$//<CR>^M
" remove quoted sig
map ,rq1 /^> *-- ^Mmt/^[^>]*$^Mkmb``d'b^M
map ,rq2 /^> *-----------^Mmt/^[^>]*$^Mkmb``d'b^M
map ,rq3 /^> *___________^Mmt/^[^>]*$^Mkmb``d'b^M

" Turn all blocks of empty lines (within current visual)
" into *one* empty line:
map ,dl :g/^$/,/./-j<CR>^M

" Condense multiple Re:'s
map ,re 1G/^Subject:<CR>:s/\(Re: \)\+/Re: /e<CR>^M

" Sven's wondeful change subject macro
map ,cs 1G/^Subject: <CR>yypIX-Old-<ESC>-W
vmap ,qp :s/^/> /<CR>^M

" Alter group reply for Black Cat.
map ,e 3G:s/^Cc:.* <\=\(.*@[^>]*\)>\=$/Bcc: \1/<CR>jddkyy1GP:s/Bcc: \(.*\)$/From: Beaujean Aurélien <\1>/<CR>jdd
" Remove email bit in from line.
map ,w 1G:s/^From:\(.*\) <.*>$/From:\1 <>/<CR>$

" Update wibble
"map ,ne 1G/<tr<CR>V/<\/td<CR>yP/dt<CR>f>lDa<C-R>=strftime("%a, %d %b %Y %H:%M:%S %z")<CR><ESC>jjV/<hr<CR>kdO<p><CR><ESC>kA

" this clears out the old colors before we begin
"highlight Constant    NONE
"highlight Delimiter   NONE
"highlight Directory   NONE
"highlight Error       NONE
"highlight ErrorMsg    NONE
"highlight Identifier  NONE
"highlight LineNr      NONE
"highlight ModeMsg     NONE
"highlight MoreMsg     NONE
"highlight Normal      NONE
"highlight NonText     NONE
"highlight PreProc     NONE
"highlight Question    NONE
"highlight Search      NONE
"highlight Special     NONE
"highlight SpecialKey  NONE
"highlight Statement   NONE
highlight StatusLine  NONE
"highlight StatusLineNC NONE
"highlight Title       NONE
"highlight Todo        NONE
"highlight Type        NONE
"highlight Visual      NONE
"highlight WarningMsg  NONE
" these are the new superior colors
"highlight Comment     term=bold ctermfg=5 ctermbg=0 guifg=#FF005F guibg=gray
"highlight Constant    term=underline ctermfg=6 guifg=#FF2f8f
"highlight Delimiter   term=bold cterm=bold ctermfg=1 gui=bold guifg=Red
"highlight Directory   term=bold ctermfg=DarkBlue guifg=Blue
"highlight Error       term=standout cterm=bold ctermbg=1 ctermfg=1 gui=bold guifg=red
"highlight ErrorMsg    term=standout cterm=bold ctermfg=1 gui=bold guifg=red
"highlight Identifier  term=underline ctermfg=3 guifg=yellow3
"highlight LineNr      term=underline cterm=bold ctermfg=3 guifg=Brown
"highlight ModeMsg     term=bold cterm=bold ctermfg=3 ctermbg=1 guifg=yellow2 guibg=red
"highlight MoreMsg     term=bold cterm=bold ctermfg=2 gui=bold guifg=Green
"highlight NonText     term=bold ctermfg=2 guifg=green3
"highlight Normal      ctermfg=white ctermbg=black guifg=grey90 guibg=#000020
"highlight PreProc     term=underline ctermfg=14 guifg=cyan
"highlight Question    term=standout cterm=bold ctermfg=2 gui=bold guifg=Green
"highlight Search      term=reverse ctermbg=2 guibg=Yellow
"highlight Special     term=bold ctermfg=5 guifg=SlateBlue
"highlight SpecialKey  term=bold ctermfg=DarkBlue guifg=Blue
"highlight Statement   term=bold ctermfg=2 gui=bold guifg=green3
highlight StatusLine  term=reverse cterm=bold ctermfg=3 ctermbg=4 guifg=wheat guibg=#2f4f4f
"highlight StatusLineNC term=bold ctermfg=3 ctermbg=2 guifg=#071f1f guibg=#5f9f9f
"highlight Title       term=bold cterm=bold ctermfg=4 gui=bold guifg=Blue
"highlight Todo        term=bold ctermfg=red ctermbg=yellow guifg=red guibg=yellow1 gui=bold
"highlight Type        term=underline cterm=bold ctermfg=3 guifg=yellow3 gui=bold
"highlight Visual      term=reverse cterm=bold ctermfg=6 ctermbg=5 guifg=yellow guibg=blue
"highlight WarningMsg  term=standout cterm=bold ctermfg=1 ctermbg=4 guifg=Red

" Editer le .vimrc
map ,v :e ~/.vimrc<CR>
" Reload le .vimrc sans quitter vim
map ,u :source ~/.vimrc<CR>

" test the auto commands
"set verbose=9

" all of this stuff allows me to write gzipped files natively...cool eh?
"autocmd BufRead *.gz set bin|%!gunzip
"autocmd BufRead *.gz set nobin
"autocmd BufWritePre *.gz %!gzip
"autocmd BufWritePre *.gz set bin
"autocmd BufWritePost *.gz undo|set nobin
"autocmd FileReadPost *.gz set bin|'[,']!gunzip
"autocmd FileReadPost set nobin

" Spécial fichier ChangeLog
autocmd BufRead ChangeLog set expandtab

" Divers...
set wig=*.o,*.obj,*~
set sw=4
set cin
set ai
set ul=200
set ch=1
set wc=<Tab>
set smd
set bs=2
"set bg=dark
"set nowrap
set smartindent
" Automatically save before commands like :next and :make
set autowrite

" instructions for VIM on processing this file
"vim:ts=3

" Taille du texte et des tabluations selon les fichiers que l'on édite
autocmd BufRead *.tex,*.latex set tw=100
autocmd BufRead *.tex,*.latex set nocin
autocmd BufRead .followup,.article,.letter,mutt* set tw=72
autocmd BufRead .followup,.article,.letter,mutt* set tabstop=8
autocmd BufRead .followup,.article,.letter,mutt* set nocin

" Mail and News autocommands
" ==========================
au BufRead ~/.article*,~/.followup,mutt* source ~/.vim/words_tools.vim
au BufRead ~/.article*,~/.followup,mutt* source ~/.vim/Mail_mutt_alias.set

" Remove quoted On blah stuff
"au BufRead ~/.article*,~/.followup,mutt* :silent! normal ,cqmh
" Remove many Re:'s from the Subject line
au BufRead ~/.article*,~/.followup,mutt* normal ,re
" Remove empty quoted lines
au BufRead ~/.article*,~/.followup,mutt* normal ,ceql
" Remove the empty lines after an unquoted On blah stuff
au BufRead ~/.article*,~/.followup,mutt* normal ,db
" Clear empty lines and turn into space to write in
au BufRead ~/.article*,~/.followup,mutt* normal ,cqel
au BufRead ~/.article*,~/.followup,mutt* normal ,cel
au BufRead ~/.article*,~/.followup,mutt* normal ,cqoq
" remove quoted signatures
au BufRead ~/.article*,~/.followup,mutt* normal ,rq1
au BufRead ~/.article*,~/.followup,mutt* normal ,rq2
au BufRead ~/.article*,~/.followup,mutt* normal ,rq3
" Remove blocks of empty lines
au BufRead ~/.article*,~/.followup,mutt* :silent! normal ,dl

" Fabien Penso - Pour copier/coller du texte dans deux sessions vim
nmap    _Y      :.w! ~/.vi_tmp<CR>
vmap    _Y      :w! ~/.vi_tmp<CR>
nmap    _P      :r ~/.vi_tmp<CR>
map     <C-Z>   :shell<CR>

" Auré
nnoremap Q gq
vnoremap Q gq
"map F {!}par -w76 -gtjq

" multiple indent (delaballe merci Matt Kunze)
noremap < <<CR>gv
noremap > ><CR>gv

" Scroll in insert mode CRTL E and CTRL Y
inoremap <C-E> <C-X><C-E>
inoremap <C-Y> <C-X><C-Y>

"noremap <F8> :so `~/bin/vimspell.sh %`<CR><CR>
"noremap <F7> :syntax clear SpellErrors<CR>

" Mail (plus utilisé car automatique cf au dessus)
"
" ,kqs = kill quoted signature 
"map ,kqs G?^> *-- $<CR>d}

" ,kpq kill SuperCite (aka PowerQuote) quote (replacing it by `>')
"map ,kpq :%s/^> *[a-zA-Z]*>/> >/<C-M>

" reformat body text to current textwidth
"map ,ref 1G/^$<CR>V/^-- $<CR><Up>Q1G
"map ,ref G?^-- $<CR><Up>V1G/^[ \t]*$<CR>Q1G

" Correction orthgraphique (megadelaballe)
map ,i :w<CR>:!aspell --mode=email -c %<CR>:e %<CR>
map ,I :w<CR>:!aspell -c %<CR>:e %<CR>

" snip (merci Nico)
vmap <buffer> ;snip c>[...]<Esc>

" Mettre/virer un bloc en commentaire
vmap <buffer> ;com :s/^/#/g<CR>
vmap <buffer> ;uncom :s/^#//g<CR>

" Affiche la date au format RFC822 - ftplugin/debchangelog. Nico
function! Date822()
    let savelang = v:lc_time
    execute "language time C"
    let dateandtime = strftime("%a, %d %b %Y %X %z")
    execute "language time " . savelang
    return dateandtime
endfunction
iab debdate <C-R>=Date822()<CR>

" Racourcis sympas
" dans le texte
iab ca ça
iab Ca Ça
iab << «
iab >> »
iab etre être
iab meme même
iab ladate <C-R>=strftime("%A %d %B %Y")<CR>
iab lheure <C-R>=strftime("%H:%M")<CR>
iab cuthere -------------------- cut here --------------------<CR><CR>-------------------- cut here --------------------

" en mode commande (trucs de fegnasse)
map ,cord iCordialement,<CR><TAB><TAB><TAB><TAB><TAB><TAB>Aurélien.<ESC>
map ,a+ iA+<CR><TAB><TAB><TAB><TAB><TAB><TAB>Auré.<ESC>
map ,aure i<CR><TAB><TAB><TAB><TAB><TAB><TAB>Auré.<ESC>
map ,demain iA demain,<CR><TAB><TAB><TAB><TAB><TAB><TAB>Aurélien.<ESC>

" Spécial Popossum
vmap <buffer> ,pik :s/ / pik /g<CR>
vmap <buffer> ,unpik :s/ pik / /g<CR>