<...>
> Which OS?
It is the same on linux, mac and windows.

To see it happen, try:
  new|exe 'norm iTest'|set fenc=utf-16le|set bomb|exe '%!xxd'|%!xxd -r

You will get a --No lines in buffer-- message from vim, and an empty buffer
where it should say Test.  Removing the last command shows that it was
fine up until trying to convert from hex back to text.

>
> On a Unix-like OS, you might try (assuming a bash-like shell)
>
>         LC_CTYPE=en_US.UTF-8 LC_ALL=  xxd

I don't think changing the locale for xxd can help - xxd converts between
7-bit ascii and untranslated binary.

My previous workaround with using latin1 only happened to work because
the file I was playing with didn't contain any unicode codepoints. Just a
case of windows using utf-16 for the joy of it.

I might have something that works for unicode buffers with BOM (see below),
but I think the real answer might be that it is reasonable to view text files in
hex mode, but it is a bit silly to want to be able to edit them.

fun! s:unhexify()
    let l:unibomb = !&binary && (&fileencoding=~#'^u') && &bomb
    if (l:unibomb)
        let l:fenc = &fileencoding
        let l:enc = &encoding
        let l:tenc = &termencoding
        setlocal fenc=utf-8
        setlocal enc=utf-8
        setlocal tenc=
    endif
    silent %!xxd -r
    if l:unibomb
        exe 'setlocal fenc='.l:fenc
        exe 'setlocal enc='.l:enc
        exe 'setlocal tenc='.l:tenc
    endif
endfun

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui