Mojca Miklavec wrote:
On 6/13/06, A.J.Mechelynck wrote:
Mojca Miklavec wrote:
> On 6/12/06, A.J.Mechelynck wrote:
>
>> You must make sure that you have:
>> - an 'encoding' which includes the non-Latin characters you want
to use
>> - (in console Vim) a terminal code page which includes them
>
> What is that? And "console vim" if you mean the one without GUI menus
> is not always there (I have it one one computer, but not on the
> other).
"Console Vim" is the one without GUI. On Windows a different executable
must be used, usually named vim.exe (or possibly something starting in
"vim" as in vimd.exe for a debug version etc.); it displays in a Dos
Box. On Unix a single executable can be used as a GUI (through X11) or
as a console version (displaying on /dev/tty or on xterm, konsole, etc.)
depending on how it is invoked.
OK, when I installed the new vim 7, it's there. It wasn't present in
the old 6.4 version, but that's not really important: I (would/will)
never use it anyway.
'guifont' empty means some default system font, such as Fixed. IMHO it
is not he prettiest but if you're satisfied with it you may stay with
it.
I don't say that it's the prettiest, but I tried to search for some
better fonts using some suggestions in "vim recipes". The problem is
that most fonts mentioned don't support Central European characters.
(And some fonts that I have need to big sizes to be readable. Lucida
Consile is the only other acceptable font that I know/have.) I would
really like to use something else, but I didn't find anything more
suitable yet.
Courier_New has a larger variety of glyphs than most other fixed-width
encodings. If Lucida_Console hasn't got the glyphs you need, I recommend
Courier_New.
There is a -menufont {font} command-line option, but from where it is
described in the help I fear it is only applicable to X11 (all
Unix/Linux versions and possibly some MacOsX versions). AFAIK the font
used for menus in Windows is common to all applications and thus outside
the reach of gvim. Try the following:
gvim -N -u NONE
:language messages
:set encoding?
Great! Thanks a lot. That did it! [grrr ... I'm so stupid that I
didn't try to remove my _vimrc file before]
I get:
Current messages language: "SL"
encoding=cp1250
The problem was that I had the following two lines in _vimrc:
set encoding=utf-8 termencoding=cp1250
This tells gvim to represent the data internally using UTF-8 but to go
on interpreting the data sent by your keyboard according to cp1250 which
is what Windows sends.
set fileencodings=ucs-bom,utf-8,cp1250
This defines the heuristics used by gvim to detect a file's charset when
opening it for editing. They are used from left to right:
- "ucs-bom": if the file starts with a BOM, the Unicode encoding
defined by the BOM is used. (The BOM is a prefix of two to four bytes,
different for all Unicode encodings, and the BOM for each encoding is
illegal in all others.) If there is no BOM, then:
- "utf-8": if the data in the file is valid for UTF-8, then Vim does
the equivalent of "setlocal fileencoding=utf-8". If it is no valid
UTF-8, then:
- "cp1250": This is an 8-bit encoding, it cannot return an "invalid"
signal. If none of the above is recognised, then the file is read
according to the Windows-1250 charset (Windows proprietary charset for
Central Europe).
I don't know how exactly each one influences the behaviour (the second
line was suggested to me on this mailing list some time ago), but I
had to comment out the first one and the problem has gone. I had
numerous problems with utf-8 before adding those lines. For some
strange reason Windows doesn't recognize vim as "being able to do
Unicode", so it communicates in an old cp1250 fashion with it. cp1250
is indeed set in the regional settings, but I didn't manage to explain
to Windows that vim can handle utf-8 as well.
OK, I only left
set fileencodings=ucs-bom,utf-8,cp1250
in my _vimrc and the menues seem to be OK now.
With these settings, you will be able to edit cp1250 files; but UTF-8
files containing codepoints not pesent in cp1250 will appear garbled
(Unicode caters for more than 10 million characters, cp1250 has only 256).
But now my second question: if I open some utf-8 file, it opens as
utf-8, which is OK. But when I open a new file and save it, it's saved
in cp1250 unless I type :set encoding=utf-8 before. So, after saying
"set encoding=utf-8" the menu stays OK, but if I put that into my
_vimrc, the encoding in menu is "broken". Any remedy for it?
Thanks a lot,
Mojca Miklavec
Since your Windows encoding is Windows-1250, I believe it would be more
"prudent" to write your menufile in cp1250 (and, I suppose, include
cp1250 in its name where there was utf-8).
See ":help ++opt" about how to set the file's charset manually when
reading or writing.
IMHO you may change 'encoding' after the menus have been set up. For
instance:
source $VIMRUNTIME/vimrc_example.vim
if &termencoding == ""
set &termencoding = &encoding
endif
set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp1250
" I believe the following will set 'fileencoding' to cp1250 by default
" for newly-created files, and set a BOM at the start of
newly-created Unicode files
setglobal fileencoding=cp1250 bomb
(Menus are set up, in your Windows default language and encoding which
are SL.cp1250, by the vimrc_example. Once the latter has been sourced,
changing the 'encoding' won't change the menus until or unless you
remove and re-add all menus.)
If the above gives you English menus, add
language messages sl_SI.cp1250
(or whatever) *before* the line for the vimrc_example.
Best regards,
Tony.