I'm using VIM 8.1.2234 with +multi_byte
and +multi_lang
In my vimrc
file, I have set listchars=tab:?\ ,trail:·
(Notice the "?" and the "·")
When I cat
or less
my vimrc, the text displays as [intuitively] expected.
When I use vim, the options behave as [intuitively] expected.
However, when I edit my vimrc, I see set listchars=tab:a<96>?\ ,trail:?·
This has not always been the case. I have not changed my VIM version but I have tweaked my vimrc a bit. I'm convinced it is a setting I tweaked but for the life of me, I cannot figure out which. I tried backing out changes, but no luck.
FWIW, I got both the "?" and the "·" characters into my vimrc via direct keyboard entry.
I don't know if it matters, but now when I open my vimrc file, I get a [converted]
flag on the status line. (My encoding is and has always been set encoding=utf-8
)
Update
I ran :verbose set fileencoding?
and got fileencoding=latin1
(despite my setting it to UTF-8) When I ran :verbose set fileencodings?
, VIM reports fileencodings=ucs-bom,utf-8,default,latin1
I tried :e ++enc=utf8 ~/.vimrc
and got [ILLEGAL BYTE in line 213]
on the status line. Line 213 is defines a macro I use for massaging specific PHP arrays into a Lua tables. Once I removed this macro line -- commenting out was not enough -- my listchars
definitions appeared correctly [while editing] and the [converted]
status tag went away.
I examined the macro definition closely (with a hex editor, as suggested) and it confirmed that all whitespace was actually whitepsace and all "normal characters" where just that, normal. I suspect that the format of the macro is confusing VIM's parser.
It was VIM's automatic encoding change from UTF-8 to Latin1 that broke listchars
. VIM, for whatever reason, gets confused by my macro definition; this is what forces VIM to change the encoding. There is no deep understanding or solution here; the issue has been cleared but the problem remains unsolved.
FWIW, here's the macro definition that [now, but didn't always] breaks VIM's parsing:
let @z = "^M^MV-%->O $data = [^[-%O? ];^M $persist( $data, \"\" );^[^M%-$F/ v$kby^M%-f\"p^M%^M^Mma-$%-mb'aV'b:s/{/[/g^M'aV'b:s/}/]/g^M'aV'b:s/: / => /g^M"
:verbose set fileencoding?
when you have your vimrc open? Do you have "utf-8" listed in:verbose set fileencodings?
(note it's plural here.) Does it work if you open the file with:e ++enc=utf-8 ~/.vimrc
?[converted]
message and result of:set
queries) is in comments only. It should be in the question, so that others reading the question and planning to write an answer could easily find all relevant information. Also for the future, when others with the same problem bump into this question after encountering a similar issue. Finding all context easily is very important!sed -n 213p problem_vimrc.txt | xxd
might be able to capture that...