" $Date: 2008-10-05 16:27:36 +0200 (Sun, 05 Oct 2008) $

" F5: Add a fortune and advance to the next one
" mX                    mark where we are
" :sp ~/.fortunes<CR>   open a window on ~/.fortunes
" gg                    go to first line
" d/^--/<CR>            delete until the next line starting with "--"
" Gp                    Go to the end and put the just deleted text there
" :wq<CR>               Write the ~/.fortunes file and close the window
" 'XG                   Go to the last line of the original file
" A<CR><Esc>            Add an empty line
" p                     put the fortune text
" `X                    return to where we started

map <F5> mX:sp ~/.fortunes<CR>ggd/^--/<CR>Gp:wq<CR>'XGA<CR><Esc>p`X



"italian accented characters
imap  a'
imap  e'
imap  i'
imap  o'
imap  u'
map <C-n> <Esc>:next<CR><End>
map <C-p> <Esc>:previous<CR><End>
imap <C-p> <Esc>:previous<CR><End>

"i don't know how this really knows..
"set encoding=latin1    "strange chars
"set encoding=utf-8     "<HH> hex encoding of unknown chars
"set encoding=unicode   "very strange chars

"italian accented characters for LaTeX
"imap <C-A> `a


" imap \'a
" imap \'e
" imap \'i
" imap \'o
" imap \'u

"filetype plugin on
"filetype ident on

imap <C-d> <Esc>:read !date +\%Y\%m\%d<CR><Esc>i<End>
map <C-d> <Esc>:read !date +\%Y\%m\%d<CR><Esc>i<End>
map <C-h> <Esc>:TOhtml<CR>:%s/<body bgcolor="#ffffff" text="#000000">/<body bgcolor="#000000" text="#ffffff">/g<Esc>


" instead of hitting <Esc> I prefer to press <C-e> in Insert Mode
imap <C-e> <Esc>


"
"map <F5> mX:sp ~/.fortunes<CR>ggd/^--/<CR>Gp:wq<CR>'XGA<CR><Esc>p`X


"the next bindings convert an entire file clean and
"dirty from italian accents

map <F6> :%!sed "s/a'/\\\\\`a/g;s/e'/\\\\\`e/g;s/i'/\\\\\`i/g;s/o'/\\\\\`o/g;s/u'/\\\\\`u/g;s//\\\\\`A/g;s//\\\\\`E/g;s//\\\\\`I/g;s//\\\\\`O/g;s//\\\\\`U/g"<CR>
map <S-F6> :%!sed "s/\\\\\`a/a'/g;s/\\\\\`e/e'/g;s/\\\\\`i/i'/g;s/\\\\\`o/o'/g;s/\\\\\`u/u'/g;s/\\\\\`A//g;s/\\\\\`E//g;s/\\\\\`I//g;s/\\\\\`O//g;s/\\\\\`U//g"<CR>


"map <F4> :%!sed"s/ò/o'/g;s/| /a'/g;s/ù/u'/g;s/è/e'/g;s/ì/i'/g"<CR>
"map <F4> :%!sed "s/ò/o'/g;s/| /a'/g;s/ù/u'/g;s/è/e'/g;s/ì/i'/g;s//A'/g;s//E'/g;s//I'/g;s//O'/g;s//U'/g"<CR>

autocmd BufReadPost *.ck set filetype=c
autocmd BufReadPost *.tex imap  \`a
autocmd BufReadPost *.tex imap  \`e
autocmd BufReadPost *.tex imap  \`i
autocmd BufReadPost *.tex imap  \`o
autocmd BufReadPost *.tex imap  \`u

" hmmm... necessary too, in my situation now 20080830
"autocmd BufReadPost *.tex imap <Char-0xc3a0> \`a
"autocmd BufReadPost *.tex imap <Char-0xc3a8> \`e
"autocmd BufReadPost *.tex imap <Char-0xc3ac> \`i
"autocmd BufReadPost *.tex imap <Char-0xc3b2> \`o
"autocmd BufReadPost *.tex imap <Char-0xc3b9> \`u
"autocmd BufReadPost *.tex imap <Char-0xc3> accentata_latex



" hmmm...
"if match(getline(0),".*/bin/.*pl")
"       set filetype=bash
"endif



" vim -b : edit binary using xxd-format!
augroup Binary
  au!
  au BufReadPre  *.bin let &bin=1
  au BufReadPost *.bin if &bin | %!xxd
  au BufReadPost *.bin set ft=xxd | endif
  au BufWritePre *.bin if &bin | %!xxd -r
  au BufWritePre *.bin endif
  au BufWritePost *.bin if &bin | %!xxd
  au BufWritePost *.bin set nomod | endif
augroup END


set nobackup
"let filetype_c = "ck"
""autocmd BufReadPost *.ck set filetype=c
"autocmd BufReadPost *.pl set syntax=prolog
autocmd BufReadPost *.prolog set syntax=prolog
autocmd BufReadPost *.m set syntax=octave
autocmd BufReadPost *.mail set syntax=mail
autocmd BufReadPost *.ypp set syntax=yacc
autocmd BufReadPost *.y++ set syntax=yacc
autocmd BufReadPost readme.marst.txt set syntax=fortran
autocmd BufReadPost *.f set ignorecase
autocmd BufReadPost *.f map f <Esc>/\<go *to\>\\|\<if\>\\|^ *\d\+<CR><End>
autocmd BufReadPost *.f map t <Esc>:tags<CR>
autocmd BufReadPost *.f map T <Esc>:ts<CR>
autocmd BufReadPost *.F90 set ignorecase
autocmd BufReadPost *.F90 map f <Esc>/\<go *to\>\\|\<if\>\\|^ *\d\+<CR><End>
autocmd BufReadPost *.F90 map t <Esc>:tags<CR>
autocmd BufReadPost *.F90 map T <Esc>:ts<CR>
autocmd BufReadPost *.f90 set ignorecase
autocmd BufReadPost *.f90 map f <Esc>/\<go *to\>\\|\<if\>\\|^ *\d\+<CR><End>
autocmd BufReadPost *.f90 map t <Esc>:tags<CR>
autocmd BufReadPost *.f90 map T <Esc>:ts<CR>
autocmd BufReadPost *.u set syntax=fortran
autocmd BufReadPost ~/.fluxbox/{keys,init,menu,slitlist,startup} set syntax=config
autocmd BufReadPost *.u set ignorecase
autocmd BufReadPost *.u map f <Esc>/\<go *to\>\\|\<if\>\\|^ *\d\+<CR><End>
autocmd BufReadPost *.u map t <Esc>:tags<CR>
autocmd BufReadPost *.u map T <Esc>:ts<CR>

autocmd BufReadPost *.fim set syntax=conf


autocmd BufReadPost ~/.fbvirc set syntax=conf
autocmd BufReadPost ~/.mutt/.*muttrc* set syntax=muttrc
autocmd BufReadPost ~/.mutt/.*/* set syntax=muttrc
autocmd BufReadPost ~/.fetchmailrc.keep set syntax=fetchmail
autocmd BufReadPost fbvirc set syntax=conf
autocmd BufReadPost *Make.inc* set syntax=make
autocmd BufReadPost *make.inc* set syntax=make
autocmd BufReadPost .octaverc set syntax=octave
autocmd BufReadPost FIM.TXT set syntax=help
autocmd BufReadPost /usr/*gcc-lib/* set syntax=cpp

function Fortran90Comments()range
        if a:firstline<a:lastline
          execute (a:firstline).",".(a:lastline).'s/^/!'
        else
          "does not happen! Vim has builtin checks for this situation
        endif
endfunction

function FortranCommentsToFortran90()range
        if a:firstline<a:lastline
          execute (a:firstline).",".(a:lastline).'s/^[Cc]/!'
        else
          "does not happen! Vim has builtin checks for this situation
        endif
endfunction


"abbreviate fc call FortranCommentsToFortran90()
"cabbrev is command line mode only
cabbrev fc call FortranCommentsToFortran90()
cabbrev resource source ~/.vimrc 

" a sort of alias for editing the  resource file
" but i'm not fully sure :D
cabbrev vimrc edit ~/.vimrc 

" print line numbers, too, and bind on short side!
set printoptions=number:y,duplex:short

" the :scriptnames command will list all loaded plugins
" or run vim --noplugin
" or:
" set loadplugins nolpl

" to disable a particular plugin

" i would like to undefine this function !
"function SearchComplete
        "
"endfunction


"This command switches on spell checking: >
"       :setlocal spell spelllang=en_us

" please someone kill /usr/share/vim/vimfiles/plugin/SearchComplete.vim
" this variable should inhibit its effect (among others, of breaking search pattern
" history lookup with the <UP> key, which I love.)
let loaded_search_complete=1

" I need a way of not loading the damn Tex autocompletion plugin!
"delf Tex_Complete
"let Tex_Completion=0
"

" when someone complains about my color scheme ...
":colorscheme morning
":colorscheme shine

"filename, help flag, modified flag, readonly flag, value of byte under
"cursor, hex value of byte under the cursor, line number, column number,
"virtual column number, percentage in file :
:set statusline=%<%f%h%m%r%=%b=0x%B\ \ l:%l,c:%c%V\ %P
":set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P
":help statusline for more

"we always want a status line
:set laststatus=2

" i light to highlight the searched text, instead of the mere pointer positioning
:set hlsearch

" when editing a program file, sometimes one wants to see the line numbers
"set number