# vim and unicode fonts



## drhowarddrfine (Apr 14, 2013)

I put together a new system and am installing vim and I'm using the i3 tiling window manager. I want to use Unicode for everything. I installed DejaVu Sans fonts and set them in urxvt-unicode for my terminal and everything seems to work there.

I am NOT using gvim. I had this problem installing vim with and without X11 graphics support (not sure which one I should use). I also turned on GTK2 toolkit support but, again, I'm not sure if I need that.

When I try to enter Unicode using vim, some of the characters I've tried show just fine by using code points but one in particular, left and right quotes using Ctl-V U201c gives me an inverted question mark. 

I did not install the Type1 fonts of TrueType yet. It's been a long time since I've done this and can't seem to figure it out. 

I'm guessing I either don't have the font installed properly or I'm not pointing to it. When I enter :set guifont? in vim it just gives me 'guifont='. I tried setting it to 'guifont=DejaVu\ Sans\ Mono' but nothing changed.

My .Xdefaults

```
URxvt.scrollBar: false
URxvt.font: xft:DejaVu Sans Mono:pixelsize=16

URxvt.background: #202020
URxvt.foreground: #cccccc
```
My .vimrc

```
if has("multi_byte")
  if &termencoding == ""
    let &termencoding = &encoding
  endif
  set encoding=utf-8
  setglobal fileencoding=utf-8
  set fileencodings=utf-8
endif
```


----------



## graudeejs (Apr 14, 2013)

You probably don't have your locale set to UTF-8 (if you have set locale at all)

Search for localization on this forum. I don't want to repeat it again.


----------



## drhowarddrfine (Apr 14, 2013)

I forgot to mention that I do have that set. I saw your previous, recent post and your dotfiles.

/etc/profile

```
LANG=en_US.UTF-8;
GDM_LANG=en_US.UTF-8;
```
It's also set in login.conf

```
:charset=UTF-8:\
:lang=en_US.UTF-8:
```
This is in my .Xdefaults

```
URxvt.scrollBar: false
URxvt.font: xft:DejaVu Sans Mono:pixelsize=16
```
EDIT: I'm doing something wrong because I do [cmd=]locale[/cmd] and LANG is not set so I need to look this up. (I'm doing this while remodeling my house **sigh**)


----------



## cpm@ (Apr 14, 2013)

Try set locale(1) routines in your ~/.cshrc

```
setenv	LANG en_US.UTF-8
setenv	LC_ALL en_US.UTF-8
```


----------



## drhowarddrfine (Apr 15, 2013)

That didn't help.


----------



## cpm@ (Apr 15, 2013)

drhowarddrfine said:
			
		

> That didn't help.



Set the encoding and terminal encoding values to UTF-8.

Then, try `% vim "+set encoding=utf-8"` 

Be sure your terminal encoding is set to UTF-8 as well [CMD=]:set termencoding=utf-8[/CMD]


> Normally 'encoding' will be equal to your current locale.  This will be the default if Vim recognizes your environment settings.  If 'encoding' is not set to the current locale, 'termencoding' must be set to convert typed and displayed text...



Also read http://vimdoc.sourceforge.net/htmldoc/options.html#%27encoding%27


----------



## drhowarddrfine (Apr 15, 2013)

I have that in my .vimrc.

I think I may have allowed this to go down the wrong path. I said earlier that I was able to enter unicode character code points, such as ctl-V u0026 gives me the ampersand sign for example, but u201c gives me an inverted question mark. This leads me to believe I somehow don't have the font installed properly or I don't have vim pointing to it properly.


----------



## graudeejs (Apr 15, 2013)

If you use .xinitrc, make sure locale is set in it as well. I do this by including ~/.profile in ~/.xinitrc https://github.com/graudeejs/dot.files/blob/master/dot.xinitrc#L2

And the line before that I set fallback locale[red]*.*[/red]


----------



## drhowarddrfine (Apr 15, 2013)

But is that assuming I don't have unicode working at all? Like I said, I can enter code points but not all of them display properly.


----------



## graudeejs (Apr 15, 2013)

Have you tried what I said?


----------



## drhowarddrfine (Apr 15, 2013)

Damn you! That works!


----------



## graudeejs (Apr 15, 2013)

He he he


----------

