" Vim html_portuguese plugin.
" Version: 1.1
"
" Description:
" When loading a html file, this plugin replaces all
" HTML-coded Portuquese (like ç) with the
" normal representation (ç).
"
" Is based on the html_umlaute by Timo Teifel .
"
" Maintainer: Rubens Marins
" Usage:
" It does everything automatically. When reading a file,
" it replaces (ç, ã etc) with the corresponding
" character encoding.
" When saving, it replaces the special Characters with the
" html-Code, undoing it after the write, to keep the chars
" if you keep working with the file.
"
" Installation:
" Save this file in vim plugin dir ( /usr/share/vim/vim61/plugin) or
" ~/.vim/plugin/html_portuguese.vim.
"
" Licence: GPL
"
" Changelog:
" v1.1 29/02/2004]
" - fixed bug typo with acute string
" v1.0 28/02/2004
" - initial release
" do this only once per buffer:
if exists("b:loaded_html_portuguese")
finish
endif
let b:loaded_html_portuguese = 1
if has("autocmd")
augroup html_portuguese
au!
au FileType html,php call s:LeHtml()
au BufWrite *.html,*.htm,*.php call s:EscreveHtml()
au BufWritePost *.html,*.htm,*.php call s:LeHtml()
augroup END
endif
" functions need to be sourced only once per session
if exists("s:loaded_html_portuguese_functions")
finish
endif
let s:loaded_html_portuguese_functions = 1
function s:LeHtml()
" remember cursor position:
let s:line = line(".")
let s:column = col(".")
" if more than 'report' substitutions have been done, vim
" displays it.
let s:save_report = &report
set report=99999
" letter 'a' 'A'
%s/ã/ã/eIg
%s/â/â/eIg
%s/á/á/eIg
%s/à/à/eIg
%s/Ã/Ã/eIg
%s/Â/Â/eIg
%s/Á/Á/eIg
%s/À/À/eIg
" letter 'e' 'E'
%s/ê/ê/eIg
%s/é/é/eIg
%s/è/è/eIg
%s/Ê/Ê/eIg
%s/É/É/eIg
%s/È/È/eIg
" letter 'i' 'I'
%s/í/í/eIg
%s/ì/ì/eIg
%s/Í/Í/eIg
%s/Ì/Ì/eIg
" letter 'o' 'O'
%s/õ/õ/eIg
%s/ô/ô/eIg
%s/ó/ó/eIg
%s/ò/ò/eIg
%s/Õ/Õ/eIg
%s/Ô/Ô/eIg
%s/Ó/Ó/eIg
%s/Ò/Ò/eIg
" letter 'u' 'U'
%s/û/û/eIg
%s/ú/ú/eIg
%s/ù/ù/eIg
%s/Û/Û/eIg
%s/Ú/Ú/eIg
%s/Ù/Ù/eIg
" latin capital letter C with cedilla,
%s/ç/ç/eIg
%s/Ç/Ç/eIg
let &report=s:save_report
unlet s:save_report
call cursor(s:line,s:column)
unlet s:line
unlet s:column
endfunction
function s:EscreveHtml()
let s:line = line(".")
let s:column = col(".")
let s:save_report = &report
set report=99999
" letter 'a' 'A'
%s/ã/\ã/eIg
%s/â/\â/eIg
%s/á/\á/eIg
%s/à/\à/eIg
%s/Ã/\Ã/eIg
%s/Â/\Â/eIg
%s/Á/\Á/eIg
%s/À/\À/eIg
" letter 'e' 'E'
%s/ê/\ê/eIg
%s/é/\é/eIg
%s/è/\è/eIg
%s/Ê/\Ê/eIg
%s/É/\É/eIg
%s/È/\È/eIg
" letter 'i' 'I'
%s/í/\í/eIg
%s/ì/\ì/eIg
%s/Í/\Í/eIg
%s/Ì/\Ì/eIg
" letter 'o' 'O'
%s/õ/\õ/eIg
%s/ô/\ô/eIg
%s/ó/\ó/eIg
%s/ò/\ò/eIg
%s/Õ/\Õ/eIg
%s/Ô/\Ô/eIg
%s/Ó/\Ó/eIg
%s/Ò/\Ò/eIg
" letter 'u' 'U'
%s/û/\û/eIg
%s/ú/\ú/eIg
%s/ù/\ù/eIg
%s/Û/\Û/eIg
%s/Ú/\Ú/eIg
%s/Ù/\Ù/eIg
" latin capital letter C with cedilla,
%s/ç/\ç/eIg
%s/ç/\Ç/eIg
let &report=s:save_report
unlet s:save_report
call cursor(s:line,s:column)
unlet s:line
unlet s:column
endfunction