4

I've recently started moving over to gvim from vim on Windows. I managed to get the terminal version set up properly, and the fonts render there.

In Vim, it works fine:

enter image description here

But in gvim, the powerline symbols are broken:

enter image description here

I'm honestly not sure where the problem lies.

The main difference between Vim in Cygwin and gvim is how the font is set up. Cygwin has a separate option for it on a window-level basis, while it appears that gvim follows set guifont.

I set both to use Source Code Pro for Powerline (also did a fresh install from powerline/fonts)

Following another post, I also tried with guifontwide, neither of which worked.

Manually adding the symbols (suggested here) results in this within gvim:

enter image description here

But in Vim, and surprisingly Notepad++, the symbols render properly.

(In theory a) minimal .vimrc (for reference, using Vim-Plug):

[...]
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-airline/vim-airline'
[...]

set guifont=Source\ Code\ Pro\ for\ Powerline:h11:cANSI " Font
set guifontwide=Source\ Code\ Pro\ for\ Powerline:h11:cANSI " gvim (?)

let g:airline_theme='tomorrow'

let g:airline_powerline_fonts = 1
let g:airline#extensions#ale#enabled = 1

" and the symbol definitions after this, but the issue is there with or without them.

The Cygwin vimrc is slightly different from the gvim vimrc, but that code (aside set guifont and set guifontwide) is present in both. Same theme, same system, same font, and overall the same plugins.

There's nothing wrong with the fonts themselves, so it's probably a configuration issue somewhere. What am I missing?

4
  • 2
    make sure you have set encoding to utf-8, needs to be the very first in your .vimrc. possibly also need to set scriptencoding to utf-8 May 28, 2019 at 17:17
  • 1
    I had termencoding set to UTF-8, replacing it with set encoding=utf-8 and set fileencoding=utf-8 actually fixed it
    – Zoe
    May 28, 2019 at 18:01
  • termencoding might still be a good idea, you should not remove it. fileencoding is a buffer-local option, it should not be set in your .vimrc file. Note, changing the encoding invalidates all stored text inside vim (registers, variables, etc), so it must be one of the first statements in your .vimrc May 29, 2019 at 6:00
  • I re-added it (figured it could be useful). I think I know why it happened too - Cygwin specified the charset with Vim, while gvim relies on the attributes. Anyway, if you post an answer, I'll accept it
    – Zoe
    May 29, 2019 at 6:07

1 Answer 1

2

Thanks to Christian Brabandt, I found the issue.

The problem is the encoding. The reason it worked in Cygwin is because I could specify the global encoding used in the terminal without any Vim config, where as gVim appears to rely more on the content of the config file.

I added this to the top of .vimrc:

set encoding=utf-8
set fileencoding=utf-8
set termencoding=utf-8

Note that this requires a gVim restart to work. Using :set encoding=utf-8 produces more visual artifacts and HTML render failure on top of the other problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.