Vim logo
" my .vimrc 007'
" .vimrc fabriqué à partir de copier/coller d'un peu partout.
" Plein de trucs importés de partout. Par miracle ça marche ensemble :)
" Plus de scripts sympa à venir! http://daniel-werner.info/
" by Daniel Werner 'Dwarf007'                                         01.2004
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

set nocompatible        " Use Vim defaults instead of 100% vi compatibility

" The looks ;-)
" ---------------------------
syntax on

" Highlight redundant whitespaces.
highlight RedundantSpaces ctermbg=blue guibg=blue
match RedundantSpaces /\s\+$\| \+\ze\t/

" Suppress all spaces at end/beginning of lines
nmap _s :%s/\s\+$//<CR>
nmap _S :%s/^\s\+//<CR>

"   pastetoggle - this toggles 'paste' so one can paste text into the terminal
"   without vim messing the text indenting up.
set pastetoggle=<f11>

" Comportement un peu plus cool
set nocompatible    " we want vim's features, not stupid vi compatiblity
set ruler               " shows ruler at the bottom of the screen
set bs=2                " allow backspacing over everything in insert mode
"set backspace=2
set backspace=indent,eol,start  " more powerful backspacing
set scrolljump=5

set ic                  " comment this out if you want to search non case sensitive
set nu                  " line numbers baby
set columns=80          " we have line number on at all times
"set linebreak           " don't break lines in the middle of a word
"set showbreak="+ "      " show this at the begining of lines that have been wrapped
set scrolloff=2         " min. number of lines above/below cursor

set showcmd             " Show (partial) command in status line

set hlsearch            " Highlight search results
set incsearch           " Search as you type
set modelines=0

set fileformats=unix    " I want to see those ^M if I'm editing a dos file. See below (Key Mappings) for ^M removal!

set expandtab           " use spaces as tabs :-)
set sts=4               " use 4 softtabstops
set sw=4                " shiftwidth fixes tab

set ignorecase          " for pattern machine
set smartcase           " Except when a mix of case is given
set exrc
set secure              " do not allow shell commands in au blocks

set swapsync=sync       " the swap is synced with sync, not fsync
set updatecount=20      " Number of characters typed before doing an update
set updatetime=500      " Number of milliseconds before doing an update
set history=100         " Number of history commands to remember
set viminfo='50,\"200   " read/write a .viminfo file, remember filemarks for 50
" files and store 200 lines of registers

set confirm             " To get a dialog when a command fails

" For debugging
"set verbose=9

" 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

" Formattage
set autoindent          " always set autoindenting on
set smartindent         " smartindent! :)
set shiftwidth=4        " spaces to use for autoindent
set tabstop=4           " spaces to use for tabstops
set nosmarttab          " always use tabstops
set expandtab           " expand tabs to spaces

" Gadgets Vim
set wildmenu
set showcmd             " get some feedback
set showmode            " show current mode
set showmatch           " show matching brackets
set shortmess=aTI       " No "welcome" message - shut up!

" Chemins & Fichiers
set path=.,/usr/include,,../include
set nobackup

" Switches match highlighting on and off
nmap <F7> :set hls!<CR>

" Switches numered lines on and off
nmap <F8> :set nu!<CR>

" Convert file format to unix
nmap _ux :se ff=unix<CR>

    " Removes those bloody ^M's
fun RmCR()
    let oldLine=line('.')
    exe ":%s/\r//g"
    exe ':' . oldLine
endfun
map <F5> :call RmCR()<CR>

" To indent the whole file without having the cursor move to the beginning or the end I have the following

fun BenIndent()
    let oldLine=line('.')
    normal(gg=G)
    exe ':' . oldLine
endfun
map -- :call BenIndent()<CR>

" HTML
" return cursor to position before closing tag
iab itd <Tab><td><CR><CR></td><Up><Up><Left>
iab itr <tr><CR><CR></tr><Up><Up><Left>
iab itable <table border='0'><CR><Tab><tr><CR><Tab><td><CR></td><CR><Home><Tab></tr><CR><Home></table>

" CTRL+o to open new file. Just type filename ;-)
map <C-o> :split

" Easy split-window shift
map <C-j> <C-W>j<C-W>_
map <C-k> <C-W>k<C-W>_
set wmh=0               " minimal height of a window, when it's not the current window

"### HTML template
        map ,web :3<cr>:r ~/.vim/header.html<cr>
        "autocmd BufRead *.html,*.htm,*.shtml,*.php,*.php3,*.php4,*.phtml source ~/.vimrc_html
        autocmd BufRead         *.html,*.htm,php3    source  ~/.vim/vimrc_html
        autocmd BufNewFile      *.html,*.htm    source  ~/.vim/vimrc_html
"### Create HTML skeleton file
        autocmd BufNewFile      *.html,*.htm    0r ~/.vim/skeleton.html
        autocmd BufNewFile      *.html,*.htm    :normal ,web

        autocmd BufNewFile      *.html,*.htm   ks|call Create_time()|'s
        autocmd BufWritePre     *.html,*.htm   ks|call LastMod()|'s
        autocmd FileWritePre    *.html,*.htm   ks|call LastMod()|'s

"### Function section
"###


function LastMod()
                let zeile = 0
                while zeile < 20
                        if getline(zeile) =~ "Last modified: "
                                exe zeile . "s/Last modified: .* ->/" . "Last modified: " . strftime("%Y-%m-%d, %T") . " ->"
                        endif
                        let zeile = zeile + 1
                endwhile
endfunction

function Create_time()
                let zeile = 0
                while zeile < 20
                        if getline(zeile) =~ "CREATE_TIME"
                                exe zeile . "s/<CREATE_TIME>/" . strftime("%Y-%m-%d, %T")
                        endif
                        let zeile = zeile + 1
                endwhile
endfunction

" Correction orthographique  - Aure
nnoremap <Leader>i :w<CR>:!aspell %<CR>:e<CR>

" Racourcis sympas dans le texte - Aure
iab ca ça
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>