On Nov 10, 6:09 pm, Christian Brabandt <[email protected]> wrote: > > autocmd FileType dosbatch :e! ++enc=cp850 > works, but put the syntax highlight off
On Nov 10, 6:16 pm, Tony Mechelynck <[email protected]> wrote: > > au BufReadPre,BufNewFile *.bat,*.btm,*.sys setlocal fenc=cp850 > don't works. On Nov 10, 6:29 pm, Ben Fritz <[email protected]> wrote: > > autocmd FileType dosbatch e ++enc=cp850 > Same as Christian Brabandt's: works, but put the syntax highlight off > I actually have something a bit more complex (I've removed some > irrelevant stuff for your immediate problem, if some of this is > confusing as-is). I use a different method, by changing > 'fileencodings' prior to loading the file, so that Vim automatically > detects my desired fileencoding: > > " Don't detect utf-8 without a BOM by default, I don't use UTF-8 > normally > " and any files in latin1 will detect as UTF. Detect cp1252 rather > than > " latin1 so files are read in correctly. Fall back to latin1 if > system does > " not support cp1252 for some reason. > exec 'set fileencodings=ucs-bom,'.s:windows_enc.',latin1' > if has('autocmd') > augroup fenc_detect > au! > > " batch files need to use the encoding of the cmd.exe prompt in > Windows > if has('win32') || has('win64') > " get the cmd.exe encoding by asking for it > let g:batcp = substitute(system('chcp'), '^\c\s*Active code > page: \(\d\+\)\s*[^[:print:]]*$', 'cp\1', '') > if g:batcp =~? '^cp\d\+$' > autocmd BufReadPre *.bat exec 'set fileencodings='.g:batcp > autocmd BufNewFile *.bat exec 'setlocal > fileencoding='.g:batcp > endif > endif > " restore default fileencodings after loading the files that use > a special > " value to force specific encodings > exec 'autocmd BufReadPost *.bat set fileencodings=ucs- > bom,'.s:windows_enc.',latin1' > augroup END > endif This works only for DOS batch files, other files are also opened in cp850. But in the Cygwin vim don't recognizes the s:windows_enc variable, I will substitute this for 'cp850' This works for me: exec 'autocmd BufReadPre *.bat set fileencodings=ucs-bom,cp850,latin1' Thank you all. Marcio. -- 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
