On 10/11/11 22:52, Marcio Gil wrote:
On Nov 10, 7:26 pm, Marcio Gil<[email protected]>  wrote:

This works for me:

exec 'autocmd BufReadPre *.bat set fileencodings=ucs-bom,cp850,latin1'


I put this in my _vimrc:

autocmd BufNewFile,BufReadPre *.bat,*.sys,*.cmd,*.prg,*.ch set
fileencodings=ucs-bom,cp850,latin1

Thank you all.

Marcio.


This won't work if you edit a batch file and then some non-batch file (*.c, *.htm, *.txt, whatever; even if you look at a Vim helpfile) in the same Vim session. Since 'fileencodings' is a global-only option, it will still be "ucs-bom,cp850,latin1" (where the latin1 part will never be used, since it is after cp850 which is 8-bit and therefore cannot give a "fail" signal), so Vim will treat that second file (if it has no BOM) as if it were in cp850 which is probably not what you want.

Maybe

        au BufNewFile,BufReadPre *
                        \ set fencs=ucs-bom,utf-8,latin1
        au BufNewFile,BufReadPre
                \ *.bat,*.sys,*.cmd,*.prg,*.ch
                        \ set fencs=ucs-bom,cp850

The autocommands will be run in the order they were defined, so that for these 5 extensions the second one takes precedence. The first one should be set to the defaults you want to use for all other files.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
214. Your MCI "Circle of Friends" are all Hayes-compatible.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to