Pour télécharger le fichier initial cliquez ici ->.vimrc

" truc/astuce vim, tips {

"g \cg : position exacte du curseur
" \cg: status du buffer.
" ga code ascii du curseur
" echo char2nr(getline('.')[col('.')-1])
" gv :pour reselectionner la derniere visual
" ctrl+n/p pour la completion
" mode ctrl+x terrible !
" :fold reduire les blocs d'instructions 
" zz me replacer au centre de l'ecran en restant au même endroit dans le text (pas M car il ne deplace pas le text)
" copie le buffer (issue d'un y) dans la ligne de commande. (Tip #383) \cr" 
" revenir a la derniere modification '.
" inverser les ligne d'une selection (sauf la premiere): :'<,'>g/./m'<
" }

" je cherche a faire: {
"  }

set guifont=-b&h-lucidatypewriter-medium-r-normal-*-*-140-*-*-m-*-iso8859-15
set encoding=iso-8859-15

set incsearch
" set digraph

autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif


set modelines=0

filetype plugin on
filetype indent on

colorscheme evening

set hlsearch
noremap <F8> :set hlsearch!<cr>:set hlsearch?<cr>

set showmatch
set scrolloff=10
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible    " Use Vim defaults (much better!)
set backspace=2     " allow backspacing over everything in insert mode
" Now we set some defaults for the editor 
set autoindent      " always set autoindenting on
set textwidth=0     " Don't wrap words by default
set nobackup        " Don't keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more than
            " 50 lines of registers
set history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the time
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

set isfname=@,48-57,/,.,-,_,+,,,#,$,%,~
" We know xterm-debian is a color terminal
if &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
  set t_Co=16
  set t_Sf=<ESC>[3%dm
  set t_Sb=<ESC>[4%dm
endif

" Vim5 comes with syntaxhighlighting. If you want to enable syntaxhightlighting
" by default uncomment the next three lines. 
"if has("syntax")
"  syntax on        " Default to no syntax highlightning 
"endif

" Debian uses compressed helpfiles. We must inform vim that the main
" helpfiles is compressed. Other helpfiles are stated in the tags-file.
set helpfile=$VIMRUNTIME/doc/help.txt.gz
autocmd BufEnter help.txt.gz,index.txt.gz,$VIMRUNTIME/doc/* nnoremap <CR> <C-]>
autocmd BufEnter help.txt.gz,index.txt.gz,$VIMRUNTIME/doc/* nnoremap <Backspace> <C-T>
autocmd BufEnter help.txt.gz,index.txt.gz,$VIMRUNTIME/doc/* nnoremap <del> <C-T>

if has("autocmd")

" Set some sensible defaults for editing C-files
augroup cprog
  " Remove all cprog autocommands
  au!

  " When starting to edit a file:
  "   For *.c and *.h files set formatting of comments and set C-indenting on.
  "   For other files switch it off.
  "   Don't change the order, it's important that the line with * comes first.
  autocmd BufRead *       set formatoptions=tcql nocindent comments&
  autocmd BufRead *.cpp,*.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
augroup END

" " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
" " This is also used when loading the compressed helpfiles.
" augroup gzip
"   " Remove all gzip autocommands
"   au!
" 
"   " Enable editing of gzipped files
"   "     read: set binary mode before reading the file
"   "       uncompress text in buffer after reading
"   "    write: compress file after writing
"   "   append: uncompress file, append, compress file
"   autocmd BufReadPre,FileReadPre  *.gz set bin
"   autocmd BufReadPre,FileReadPre  *.gz let ch_save = &ch|set ch=2
"   autocmd BufReadPost,FileReadPost    *.gz '[,']!gunzip
"   autocmd BufReadPost,FileReadPost    *.gz set nobin
"   autocmd BufReadPost,FileReadPost    *.gz let &ch = ch_save|unlet ch_save
"   autocmd BufReadPost,FileReadPost    *.gz execute ":doautocmd BufReadPost " . expand("%:r")
" 
"   autocmd BufWritePost,FileWritePost  *.gz !mv <afile> <afile>:r
"   autocmd BufWritePost,FileWritePost  *.gz !gzip <afile>:r
" 
"   autocmd FileAppendPre           *.gz !gunzip <afile>
"   autocmd FileAppendPre           *.gz !mv <afile>:r <afile>
"   autocmd FileAppendPost      *.gz !mv <afile> <afile>:r
"   autocmd FileAppendPost      *.gz !gzip <afile>:r
" augroup END
" 
" augroup bzip2
"   " Remove all bzip2 autocommands
"   au!
" 
"   " Enable editing of bzipped files
"   "       read: set binary mode before reading the file
"   "             uncompress text in buffer after reading
"   "      write: compress file after writing
"   "     append: uncompress file, append, compress file
"   autocmd BufReadPre,FileReadPre        *.bz2 set bin
"   autocmd BufReadPre,FileReadPre        *.bz2 let ch_save = &ch|set ch=2
"   autocmd BufReadPost,FileReadPost      *.bz2 |'[,']!bunzip2
"   autocmd BufReadPost,FileReadPost      *.bz2 let &ch = ch_save|unlet ch_save
"   autocmd BufReadPost,FileReadPost      *.bz2 execute ":doautocmd BufReadPost " . expand("%:r")
" 
"   autocmd BufWritePost,FileWritePost    *.bz2 !mv <afile> <afile>:r
"   autocmd BufWritePost,FileWritePost    *.bz2 !bzip2 <afile>:r
" 
"   autocmd FileAppendPre                 *.bz2 !bunzip2 <afile>
"   autocmd FileAppendPre                 *.bz2 !mv <afile>:r <afile>
"   autocmd FileAppendPost                *.bz2 !mv <afile> <afile>:r
"   autocmd FileAppendPost                *.bz2 !bzip2 -9 --repetitive-best <afile>:r
" augroup END

endif " has ("autocmd")

" Some Debian-specific things
augroup filetype
  au BufRead reportbug.*        set ft=mail
augroup END

" The following are commented out as they cause vim to behave a lot
" different from regular vi. They are Highly recommended though.
"set showcmd        " Show (partial) command in status line.
"set showmatch      " Show matching brackets.
"set ignorecase     " Do case insensitive matching
"set incsearch      " Incremental search
"set autowrite      " Automatically save before commands like :next and :make
" auto indentation pour la programmation
" permet d'avoir la position
set et
set tabstop=4
set shiftwidth=4

"mes fichier sont unix tout le temps
set fileformats=unix
set formatoptions=rtql

" pas de copie de sauvegarde
set nobackup

" syntax keyword moi MichouX
hi moi ctermfg=darkblue guifg=#000099

" permet les couleurs pour la prog
" autocmd BufRead *.sh,*.c,*.h,*.pl,mutt*,*.php,*.php3,*.html,*.htm syntax on
syntax on

" pour la prog avec mots clés
autocmd BufRead *.html,*.htm set ft=html
autocmd BufRead *.php,*.php3 set ft=php
autocmd BufRead *.c,*.h set ft=c
autocmd BufRead .followup,.article*,.letter,/tmp/mutt*,*.txt set ft=mail
autocmd BufRead *.sh set ft=sh
autocmd BufRead *.pl set ft=perl

" commente/decommenter auto
autocmd BufEnter *.sh,*.pl,*rc vmap ;com :s/^/# /<CR>
autocmd BufEnter *.sh,*.pl,*rc vmap ;uncom :s/^#[<TAB> ]//<CR>
autocmd BufEnter *.htm,*.html,*.xml,*.wml vmap ;com :<backspace><backspace><backspace><cr>O<!--<esc>:'><cr>o--><esc>
autocmd BufEnter *.html,*.php,*.php3 vmap ;table :<backspace><backspace><backspace><cr>O<table><esc>:'><cr>o</table><esc>
autocmd BufEnter *.html,*.php,*.php3 vmap ;tr <tab>O<tab><tr><esc>:'><cr>o<tab></tr><esc>
autocmd BufEnter *.html,*.php,*.php3 vmap ;td <tab>O<tab><td><esc>:'><cr>o<tab></td><esc>
autocmd BufEnter *.html,*.php,*.php3 vmap ;form <tab>O<tab><form action=\".\" method=get enctype=\"text/plain\"><esc>:'><cr>o<tab></form><esc>
autocmd BufEnter *.php,*.php3 nnoremap gx yiw/^\(sub\<bar>function\)\s\+<C-R>"<CR>
autocmd BufEnter *.vimrc vmap ;com :s/^/" /<CR>
autocmd BufEnter *.vimrc vmap ;uncom :s/^"[<TAB> ]//<CR>
autocmd BufEnter *.php,*.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l vmap ;com :s/^/\/\/ /g<CR>
autocmd BufEnter *.php,*.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l vmap ;uncom :s/^\/\/[<TAB> ]//g<CR>
" map! ^? <ESC>lxi
" nnoremap ^? x
" nnoremap ^H hx

set noautoindent

" ajout  accolade
" map! ^A <ESC>:.,$g/^[     ]*$/d<CR>i
" nnoremap ^A :.,$g/^[  ]*$/d<CR>

autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l map! ^A {<ESC>o}<ESC>O
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l nnoremap ^A o{<ESC>o}<ESC>O

"delete
"map! <ESC>[3~ <ESC>lxi
" nnoremap <ESC>[3~ x

" backspace   | | 
" map! <S- > <M- >
map! ^? <backspace>
" nnoremap ^? hx
" map! <ESC>Oq 1
" map! <ESC>Or 2
" map! <ESC>Os 3
" map! <ESC>Ot 4
" map! <ESC>Ou 5
" map! <ESC>Ov 6
" map! <ESC>Ow 7
" map! <ESC>Ox 8
" map! <ESC>Oy 9
" map! <ESC>OQ /
" map! <ESC>OR *
" map! <ESC>OS -
" map! <ESC>Ol +
" map! <ESC>OM <CR>
" map! <ESC>On .
" map! <ESC>Op 0
nnoremap ^[[2~ 0
nnoremap ^[[4~ $
map! ^[[2~ <esc>I
map! ^[[4~ <esc>A

"tabulation
nnoremap <TAB> >>
" nnoremap <ESC>[Z <<
vnoremap <TAB> >
" vnoremap <ESC>[Z <
" vnoremap <SHIFT><TAB> <
inoremap ^] <esc>O
inoremap ^\ <esc>o

" Editer le .vimrc 
nnoremap ;v :split ~/.vimrc " <CR>:source ~/.vimrc<CR>
" Reload le .vimrc sans quitter vim
" autocmd BufLeave .vimrc :source ~/.vimrc<CR>
" autocmd BufWritePost ~/.vimrc :source ~/.vimrc

" pour le c
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab def <ESC>:0<CR>O#define
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab de <ESC>:0<CR>/#define<CR>O#define
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab inc <ESC>:0<CR>O#include
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab in <ESC>:0<CR>/#include<CR>O#include
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab For for()<CR>  {<CR>   <ESC>o  }<ESC>3k03li
autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l inoreab While while()<CR>  {<CR>   <ESC>o  }<ESC>3k$i
" autocmd BufEnter *.c,*.h,*.cc,*.C,*.H,*.hh,*.cpp,*.cxx,*.c++,*.y,*.l set noautoindent

"marche pas sur deb apparement...
" highlight Search      term=reverse ctermbg=2 guibg=Yellow

set foldmethod=marker
" set foldmarker={,}
" set foldminlines=5
" highlight Folded ctermbg=0 ctermfg=7

" mails
"permet de faire des lignes de 60 caracteres
autocmd BufRead .followup,.article*,.letter,/tmp/mutt*,*.txt,.signature*,signature* set tw=60
autocmd BufRead .followup,.article*,.letter,/tmp/mutt*,*.txt,.signature*,signature* set foldmethod=manual
autocmd BufRead .followup,.article*,.letter,/tmp/mutt*,*.txt,.signature*,signature* set comments+=n:\|
" autocmd BufRead .followup,.article*,.letter,/tmp/mutt*,*.txt,.signature*,signature* set comments=fs1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,n:\|

" pour insert le followup automatiquement.
nnoremap ;fu /Newsgroups<CR>wlDp/Followup-To:<CR>/: <CR>plD
"pour aller au debut du message
nnoremap ;vide gg<CR>/^$<CR>
" nnoremap ;par ;vide<CR>:.,$normal vgq<CR>
" nnoremap ;par :exec '.,$g/^.\{'.&tw.'\}.\+$/normal V)gq'<CR>
" /^.\{75\}.\+$<CR>v/\.$<CR>gqj

 function s:Par()
    let fin_range_delta=line('$')-search('^-- $','W')
    echo "range delta de fin : " . fin_range_delta
" je commence a la premiere ligne vide (après les headers)
    normal! G
    let pos = search('^$')
    let oldpos = pos
    echo "definition de pos:" . pos
" je vais a la fin puis remonte au dessus de la signature.
    let pos = search('^.\{'.&tw.'\}.\+$', 'W')
" je me place au debut de ce que je dois traiter.
    while ( pos < line('$')-fin_range_delta ) && ( oldpos < pos )
        if pos < 1
            break
        endif
" detection de la fin du paragraphe.
        let end = pos
        let end = search('\(^\(> \)*\|[:;=][-o]\?[pD{[(/\\}\])]\|[:.!?]\)\s*$', 'W')
        let delta = end - pos
echo "mise en page de " . pos . " sur " . delta ." lignes."
        if delta <= 0
            exe pos.'normal! gqq'
        else
            exe pos.'normal! gq'.delta.'j'
        endif
        let oldpos = pos
        let pos = search('^.\{'.&tw.'\}.\+$', 'W')
     endwhile
 endfunction

autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;para gg:call <sid>Par()<cr>

nnoremap ;é :silent! %s/~E/é/g<CR>
nnoremap ;' :silent! %s/~R/'/g<CR>
nnoremap ;oe :silent! %s/~\/oe/g<CR>
nnoremap ;MM :silent! %s/\r//g<CR>gg
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;redu  :silent! %s/\(^[> ]\+\)\(\n^[> ]\+$\)\+/\1/<CR>
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;rmsig G:silent! /^>[> ]*-- $<CR>:.,$g/^>[> ]*/d<CR>
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;rmyahoo G:silent! /^>[> ]*=====$<CR>:.,$g/^>[> ]*/d<CR>
" pour elever le reste des quotes
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap <C-S> :.,$g/^>[ >]\?/d<CR>i
"pour aller a la prochaine quote vide.
" autocmd BufRead .followup,.article*,.letter,/tmp/mutt* map! <C-S> <ESC>md/^\(>[ >]\+\\|\)$<CR>C
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* map! <C-S> <ESC>j/^\(>[ >]\+\\|\)$<CR>C
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* map! <C-T> <esc>g`da

vnoremap <buffer> ;snip dO> [snip]<Esc>
vnoremap <buffer> ;... dO> [...]<Esc>

" signatures.
" efface la signature courante
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;sig  mS/^-- $<CR>V}c-- <esc>:r!~/bin/signature.pl<CR>`S
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;cord mS/^-- $<CR>V}c-- <CR>Cordialement,<CR>    Sébastien MICHEL<ESC>`Sl
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;talc mS/^-- $<CR>V}c-- <ESC>:r ~/.signature.cord<CR>`Sl
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;rega mS/^-- $<CR>V}c-- <CR>Regards,<CR>    Sébastien MICHEL<ESC>`Sl
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;salu mS/^-- $<CR>V}c-- <CR>Dans l'attente d'une réponse je vous prie d'agréer mes salutations distinguées,<CR>    Sébastien MICHEL<ESC>`Sl
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* inoremap ;sig    <esc>;sig
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* noremap! ;rega   <esc>;rega
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* noremap! ;salu   <esc>;salu
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* noremap! ;cord   <esc>;cord
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* noremap! ;talc   <esc>;talc
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;cv :normal i;cv<cr>
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;was gg/^Subject<CR>2wi[was: <ESC><END>a ]<ESC>0wli
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* nnoremap ;tip gg/^Subject<CR>2wi[tip] <ESC>:normal ;vide<CR>
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* noremap! ;cv Vous trouverez mon CV au format html attaché à ce mail ainsi que sur mon site web: http://michoux.born2frag.org/CV/

autocmd BufRead .followup,.article* normal ;fu
" passer directement au message
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;MM
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;para
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;redu
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;rmsig
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;rmyahoo
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;'
autocmd BufRead .followup,.article*,.letter,/tmp/mutt* normalautocmd BufRead .followup,.article*,.letter,/tmp/mutt* normal ;vide


inoreab bientot bientôt
inoreab arrete arrête
inoreab dasn dans
inoreab dsna dans
inoreab dnas dans
inoreab ;à ;p
inoreab ca ça
inoreab Ca Ça
inoreab apres après
inoreab aprés après
inoreab tres très
inoreab etre être
inoreab Etre Être
inoreab meme même
inoreab deja déjà
inoreab decu deçu
inoreab recu reçu
inoreab etait était
inoreab etais étais
inoreab ecris écris
inoreab paris Paris
inoreab Sebastien Sébastien
inoreab tlse Toulouse
inoreab toulouse Toulouse
inoreab facon façon
inoreab fete fête
inoreab helene Hélène
inoreab ;H häagen-dazs
inoreab urlfamille http://famille:XXXXX@nospam.born2frag.org/famille/
inoreab urlparis http://b2f:XXXXX@nospam.born2frag.org/paris/
inoreab urlft http://ft:XXXXX@nospam.born2frag.org/foyerft/


" Fabien Penso - Pour copier/coller du texte dans deux sessions vim
nnoremap    _Y      :.w! ~/.vi_tmp<CR>
vnoremap    _Y      :w! ~/.vi_tmp<CR>
nnoremap    _P      :r ~/.vi_tmp<CR>
nnoremap     <C-Z>   :shell<CR>
nnoremap     ^[[c   :bn<cr>
nnoremap     ^[[d   :bp<cr>
nnoremap     ^[[a   :ls<cr>
inoremap     ^[[c   <esc>:bn<cr>
inoremap     ^[[d   <esc>:bp<cr>
inoremap     ^[[a   <esc>:ls<cr>
"nnoremap     <C-N>   :bn<cr>
"nnoremap     <C-P>   :bp<cr>
"inoremap     <C-N>   <esc>:bn<cr>
"inoremap     <C-P>   <esc>:bp<cr>
"inoremap     <C-L>   <esc>:ls<cr>


" nnoremap     <C-O>   T vt y:split <C-R>"<CR>

" pour mon signature.pl
autocmd BufRead signature*  nnoremap    ;ins /^}$<CR>zvO}elsif ($num==$REF++)<CR>{<CR>print "$SIG <CR>\"<CR>\"<CR>";<ESC>kka
autocmd BufRead blog        nnoremap    ;ins :0<cr><cr>µ<cr>MichouXµ<esc>:r!date +\%e/\%m/\%Y<cr><cr><esc>:0<cr>i
autocmd BufRead blog        nnoremap    ;up o<b><u>UPDATE&nbsp;:</u></b><br/><esc>F<i


" highlight Normal  ctermfg=white ctermbg=black
highlight Folded    ctermfg=blue ctermbg=black
highlight Search term=reverse ctermbg=blue ctermfg=White guibg=blue guifg=White
highlight Visual term=reverse ctermbg=blue gui=reverse guifg=Grey guibg=fg
highlight WildMenu term=standout ctermbg=Black ctermfg=blue guibg=Yellow guifg=blue
set dictionary=~/.vim/dictionary

" set foldmethod=syntax