Jan Weytjens wrote:
Hi Tony,
Ah. That's bad. Vim 7.0 on W2K aren't you.

What are the answers to:
   gvim -N -u NONE
   :set encoding?
latin1
   :lang cty
Current ctype language: "C"
   :echo char2nr('²')
178
   :echo char2nr('µ')
181

and to
   gvim
   :verbose set enc? tenc?
encoding = latin1
termencoding = latin1
   Last set from c:\Program Files\Vim\_vimrc
   :set enc=latin1
   :map ²
   :map! ²
   :map µ
   :map! µ
No mapping found
(for all of them)
   :set enc=utf-8
This gives the following error message:

Error detected while processing EncodingChanged Auto commands for "*":
E492: Not an editor command: SpecialMaps()

I have included my _vimrc (adapted according to your suggestions)
   :map ²
   :map! ²
   :map µ
   :map! µ
Best regards,

Jan

------------------------------------------------------------------------

scriptencoding latin1
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

" My stuff
set dir=c:\tmp
set expandtab
set hls
set nobackup
set nowritebackup
set number
set printoptions=syntax:y
set shiftwidth=2
set tabstop=2
set showtabline=2

imap <! <!--

-->ki
nmap <! i<!

nmap <F6> :buffers<CR>
nmap <F7> :bp<CR>
nmap <F8> :bn<CR>

" Replace tabs by 2 spaces
nmap <F11> :%s/\t/  /g<CR>
" Remove trailing white space
nmap <F12> :%s/\s\+$//<CR>
"nmap ² ~
"imap ² ~
"cmap ² ~
nmap % :vsplit<CR>

" Move to beginning/end of function
nmap <M-{> mx <bar> ?^{
imap <M-{>  mx <bar> ?^{
nmap <M-}> mx <bar> /^}
imap <M-}>  mx <bar> /^}

let &termencoding = &encoding

augroup cprog
" Remove all cprog autocommands
  au!
  " Set formatting of comments and set C-indenting on for C, C++, CSS and Java 
files
  " Switch it off for other files.
  " (The line with * must come first)
  autocmd FileType *          set formatoptions=tcql nocindent comments&
  autocmd FileType c,cpp,css  set formatoptions=croql cindent 
comments=sr:/*,mb:*,ex:*/,://
  autocmd FileType java       set formatoptions=croql cindent 
comments=sr:/*,mb:*,ex:*/,sr:/**,mb:*,ex:*/,://
  autocmd FileType c,cpp,css,java,xml,xsd set nu
  autocmd FileType c,cpp,css,xml,xsd set shiftwidth=2
  autocmd FileType c,cpp,css,xml,xsd set tabstop=2
  autocmd FileType c,cpp,css,xml,xsd set textwidth=80
  autocmd FileType xml,xsd,wsdl set encoding=utf-8
  autocmd FileType xml,xsd,wsdl set fileencoding=utf-8
  autocmd FileType java       set shiftwidth=4
  autocmd FileType java       set tabstop=4
augroup END

function! SpecialMaps()
  silent! unmap  <Char-178>
  silent! unmap! <Char-178>
  exe 'noremap  <Char-178> <Char-126>'
  exe 'noremap! <Char-178> <Char-126>'
endfunction
if has("autocmd") && version >= 700
  augroup vimrcmaps
    au! EncodingChanged * SpecialMaps()
  augroup END
endif

" Plugins
let g:EnhCommentifyUseAltKeys = 'Yes'
Oops! My bad. The autocommand should be

   au! EncodingChanged * call SpecialMaps()

(I forgot the "call" verb.)

Note: I am no professional Vim tech, just a plain user like everyone on this list. Except when straying off-topic, please use "Reply to All" rather than "Reply to Sender" so that everyone has a chance to reply if by any chance I don't, or if (like here) I goof.


Best regards,
Tony.

Reply via email to