Emoji not displaying correctly when using vim or tmux

emojifontsterminal

I am running Tilix on Arch Linux. I am having problems with emoji display when running vim or tmux, even though things work correctly in the same terminal when not running vim or tmux.

For demonstration purposes, I have a shell script called smile that looks like this:

#!/bin/sh

echo '?'

When run on the terminal, it produces:

enter image description here

But when running tmux on the same terminal, I get:

enter image description here

And if I open the script in vim I see:

enter image description here

On my Fedora 31 system, also running Tilix (under Gnome), all of the above works just fine: the emoji displays correctly under tmux and in vim.

Any thoughts on what could be going on here?

Best Answer

You need proper Unicode all the way up the stack from OS-Locale, to Terminal, to Tmux, to Vim. Each part of the chain must support Unicode properly.

For your OS-Locale

you need something like: set LANG="en_US.UTF-8"

For Tmux

Try starting tmux using tmux -u, like Jon suggested. If that doesn't work then you might need to check your config files .tmux.conf or reset to default.

FOR VIM

You need to compile vim with multi-byte support.

The easiest way to do this is to run

./configure --with-features=big
make

This will build vim with the correct support.

You can verify that it was compiled correctly with

:version

in vim or by running

vim --version

and looking for +multi_byte. If it says -multi_byte it will not work.

Related Question