Created attachment 1497580 [details] patch do /etc/vimrc Description of problem: File /etc/vimrc start with the following: if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set fileencodings=ucs-bom,utf-8,latin1 endif If this settings is inappropriate, there is no way to change it from command line (or script) starting vim/gvim This makes starting gvim for editing files in 8-bit encodings like cp-1250, cp-852, etc, cumbersome Version-Release number of selected component (if applicable): any How reproducible: Any file in 8-bit encoding will be opened as if it were in latin1 Steps to Reproduce: 1. Generate test file mkdir /dev/shm/vimtest chdir /dev/shm/vimtest echo zażółć gęślą jaźń | iconv -f utf-8 -t cp1250 > testfile.txt 2. Open test file with gvim: 2A) gvim -R testfile.txt or, 2B) gvim -R --cmd 'set fencs=cp1250' testfile.txt 3. on Gvim prompt: :echo &fileencoding Actual results: Garbled characters, I am not aware of any method of setting fileencodings from command line, as it gets changed by /etc/vimrc lines 1-3 Expected results: starting gvim as in 2B) should respect fileencodings value specified on command line Additional info: If I enter commands within vim :set fencs=cp1250 :e! The file is displayed properly 4. Patch proposal Please consider replacing first 3 lines in /etc/vimrc with the following: if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" if empty(&fileencodings) set fileencodings=ucs-bom,utf-8,latin1 endif endif After that change setting fileencodings from command line via --cmd parameter seems to work (and 2B displays file correctly).
Hi Wojciech! thank you for filing the issue and the patch! Actually we can get the same behavior if I remove the mentioned 'if' statement from vimrc, so I was trying to investigate why that 'if' is even there for (there is no git message about the change, because it was imported even from CVS long time ago...). It seems like it is checking if v:lang variable has utf8 or UTF-8 strings at the end... Karsten, do you have any idea why it is in default /etc/vimrc? Because Vim sets those values automatically if encoding is utf-8. I can remove this if for now and see if anyone will complain about it...
I've added ucs-bom to that line in 2008, the rest is from 2004. I couldn't find any traces where it came from, but I didn't dig very deep. It might have been in the upstream vimrc.example back then. vim has changed a lot in the meantime and handles defaults much better. I'd recommend to compare our /etc/vimrc with the current upstream vimrc.example and runtime/defaults.vim and use the upstream vimrc with some of our changes.
I merged defaults.vim with our vimrc and removed fileencodings settings, because it seems vim sets it co rrectly now. It is fixed in 8.1.1713-1 which will arrive in bodhi in hour or two. Beware: vimrc is set as config file, so it will not be replaced automatically, you need to replace it manually.
FEDORA-2019-c008d1f32c has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-c008d1f32c
vim-8.1.1713-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-c008d1f32c
vim-8.1.1713-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.