Turns out the problem was that vim on the remote was not compiled with GTK. This happened because the necessary package was not present on the remote box. Thus, even with the --enable-gtk2-check
compile flag set, it was not actually including GTK.
To fix it, log on to the remote machine and:
- Install gtk2-devel,
- re-configure, re-make, & re-install vim
A co-worker figured this out eventually.
Writing in 2016, talking about xterm patch #278 (released in 2012):
xterm uses a single font, rather than font sets which are supported by several other terminals. The pseudo-graphic characters in this (pasted from xterm):
⎛ ⎽⎽⎽⎽⎽⎽⎽ ⎞
⎜ ╱ 3 ⎟
⎜ ╱ x ⎟
⎜ ╱ ───── , 1⎟
⎝╲╱ x + 1 ⎠
are not provided by the TypeType font specified here:
xterm.vt100.faceName: Terminus
xterm.vt100.faceSize: 14
Other terminals, given that font would provide those characters from another font.
The way to make xterm work is
- specify a font which does cover all of the characters needed, and
- tell it to use UTF-8 encoding.
The latter is addressed for most users by the default setting of the locale
resource: xterm will (usually) use UTF-8 encoding. But the default behavior is VT100-compatible, hence the use of ISO-8859-1 compatible fonts.
- Terminus uses more glyphs than that, but falls far short of covering all pseudo-graphics in Unicode.
- The ones that display as
n
are U+239B, U+239C, U+239D, U+239E, U+23A0.
- The version of Terminus in Debian 7 (and Debian testing) has less than 256 glyphs and happens to show
n
as described in the question.
That happens because (although xterm knows that the glyphs are missing), it has printed the string using the font, assuming that (like most other fonts) missing entries will be shown as blanks. In this case, the freetype library seems to be mapping the low-order byte of the Unicode values into the range that Terminus supports. That happens to fall in a range that the font displays as n
(for "no such character"):
The quick workaround uses the uxterm
script, which selects a different font and ensures that UTF-8 encoding is used.
Further reading:
Terminus Font is a clean, fixed width bitmap font, designed for long (8 and more hours per day) work with computers. Version 4.40 contains 1241 characters, covers about 120 language sets and supports ISO8859-1/2/5/7/9/13/15/16, Paratype-PT154/PT254, KOI8-R/U/E/F, Esperanto, many IBM, Windows and Macintosh code pages, as well as the IBM VGA, vt100 and xterm pseudographic characters.
The above was talking about xterm patch #278 which was four years old in 2016. Development of xterm is ongoing, and beginning with patch #338 (late 2018) there is support for TrueType fontsets. Here is a screenshot using the OP's resource-settings from xterm patch #342 (#343 will probably be out "soon"):
Using the -report-fonts
option, I see that it loaded these font-files (treating bold/italic as the "same" as normal, and using a second font for the special characters):
file=/usr/share/fonts/X11/misc/ter-u18n\_iso-8859-1.pcf.gz
file=/usr/share/fonts/X11/misc/ter-u18b\_iso-8859-1.pcf.gz
file=/usr/share/fonts/X11/misc/ter-u18n\_iso-8859-1.pcf.gz
file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
The actual number of fonts depends on what you want to do. In testing the existing range of Unicode values, it may use a couple of dozen fonts.
Best Answer
I'll start with Xterm because it is the most complicated one. Kitty and Urxvt are tackled at the end.
X-resources
The
~/.Xresources
file configures Xterm (and some other Xlib applications). Whenever you are done editing it, issuexrdb ~/.Xresources
and open a new Xterm to test the changes. Start withSee
man xterm
or configuring Xterm for further options, such as colors and fonts — the defaults are admittedly ugly.Sending keycodes
We will follow Leonerd's article proposal, and have the terminal send
CSI codepoint;modifier u
, whereCSI stands for an Esc character followed by
[
.codepoint is the decimal Unicode value of the character to be mapped. ASCII characters have the same decimal representation in Unicode.
modifier is chosen from the table below:
Ctrl-Shift-x
Look up
X
in an ASCII table and find that its decimal value is 88. ThereforeCSI 88;5 u
should be sent to Vim. This goes in.Xresources
:Ctrl-Shift-x now produces the sequence in quotes. A tilde negates the modifier, i.e.,
~Meta
means that Alt is not pressed (Meta means Alt).033
is Esc in octals.There should be no spaces after the backslashes (Xrdb would warn you of the mistake) and, as will be seen ahead, multiple bindings should be separated from each other with
\n\
.Tab and Ctrl-i
i
is decimal 105 andTab
is decimal 9, but both Ctrl-i and Tab send 9, as the ASCII table article explains. So Ctrl-i must send a different sequence to disambiguate them, and by the same reasoning as before, we conclude it isCSI 105;5 u
.One could also add
~Ctrl ~Meta ~Shift <Key>Tab :string("\011")
but that would be redundant sinceTab
already sends decimal 9 (octal 11).Modified
Tab
is special as listed under "Modified C0 controls".More special keys
Here belong F1-F12, Home and others. In Xterm they already have unambiguous codes, which can be straightforwardly determined by pressing Ctrl-vKey in Vim's insert mode. For example, Ctrl-vCtrl-F1 produces
<ESC>[1;5P
.Vimrc
Now we just have to add the bindings to
.vimrc
:The 5th line is very important: Ctrl-i, used to move back in the jump list, is not Tab anymore in Xterm; instead it sends a different sequence to Vim, thus that sequence should be mapped to what Vim has under Ctrl-i.
Extra notes
If you notice a delay when Esc is pressed in insert mode, adjust Vim's timeout settings, e.g.
set timeoutlen=1000 ttimeoutlen=20
(see timeoutlen vs ttimeoutlen).If in doubt what keysym should go in
.Xresources
, usexev
to find it out. For example, pressing the left Windows/Super key outputsSuper_L
.In Xterm, Ctrl-Q and Ctrl-S are reserved for flow control, a legacy feature. To map them, first deactivate flow control by adding
to
.vimrc
.To make the maps invisible to other TUI programs, you can keep Vim under a different Xterm classname, such as
and use
vimterm
instead ofXTerm
in the.Xresources
file. How to open new files in a same Vim instance may prove helpful.Other terminal emulators: Urxvt and Kitty
Urxvt uses a different syntax in
.Xresources
. A interfering binding caused by ISO 14755 also has to be disabled.Kitty does not use
.Xresources
, the bindings go in~/.config/kitty/kitty.conf
: