*digraph.txt* For Vim version 8.2. Last change: 2020 Jul 16
VIM REFERENCE MANUAL by Bram Moolenaar
Digraphs *digraph* *digraphs* *Digraphs*
Digraphs are used to enter characters that normally cannot be entered by
an ordinary keyboard. These are mostly printable non-ASCII characters. The
digraphs are easier to remember than the decimal number that can be entered
with CTRL-V (see |i_CTRL-V|).
There is a brief introduction on digraphs in the user manual: |24.9|
An alternative is using the 'keymap' option.
1. Defining digraphs |digraphs-define|
2. Using digraphs |digraphs-use|
3. Default digraphs |digraphs-default|
==============================================================================
1. Defining digraphs *digraphs-define*
*:dig* *:digraphs*
:dig[raphs][!] Show currently defined digraphs.
With [!] headers are used to make it a bit easier to
find a specific character.
*E104* *E39*
:dig[raphs] {char1}{char2} {number} ...
Add digraph {char1}{char2} to the list. {number} is
the decimal representation of the character. Normally
it is the Unicode character, see |digraph-encoding|.
Example: >
:digr e: 235 a: 228
< You can use `:exe` to enter a hex number: >
:exe 'digr += ' .. 0x2A72
< Avoid defining a digraph with '_' (underscore) as the
first character, it has a special meaning in the
future.
Vim is normally compiled with the |+digraphs| feature. If the feature is
disabled, the ":digraph" command will display an error message.
Example of the output of ":digraphs": >
TH Þ 222 ss ß 223 a! à 224 a' á 225 a> â 226 a? ã 227 a: ä 228
The first two characters in each column are the characters you have to type to
enter the digraph.
In the middle of each column is the resulting character. This may be mangled
if you look at it on a system that does not support digraphs or if you print
this file.
*digraph-encoding*
The decimal number normally is the Unicode number of the character. Note that
the meaning doesn't change when 'encoding' changes. The character will be
converted from Unicode to 'encoding' when needed. This does require the
conversion to be available, it might fail. For the NUL character you will see
"10". That's because NUL characters are internally represented with a NL
character. When you write the file it will become a NUL character.
Example: >
digraph oe 339
This defines the "oe" digraph for a character that is number 339 in Unicode.
==============================================================================
2. Using digraphs *digraphs-use*
There are two methods to enter digraphs: *i_digraph*
CTRL-K {char1} {char2} or
{char1} <BS> {char2}
The first is always available; the second only when the 'digraph' option is
set.
If a digraph with {char1}{char2} does not exist, Vim searches for a digraph
{char2}{char1}. This helps when you don't remember which character comes
first.
Note that when you enter CTRL-K {char1}, where {char1} is a special key, Vim
enters the code for that special key. This is not a digraph.
Once you have entered the digraph, Vim treats the character like a normal
character that occupies only one character in the file and on the screen.
Example: >
'B' <BS> 'B' will enter the broken '|' character (166)
'a' <BS> '>' will enter an 'a' with a circumflex (226)
CTRL-K '-' '-' will enter a soft hyphen (173)
The current digraphs are listed with the ":digraphs" command. Some of the
default ones are listed below |digraph-table|.
For CTRL-K, there is one general digraph: CTRL-K <Space> {char} will enter
{char} with the highest bit set. You can use this to enter meta-characters.
The <Esc> character cannot be part of a digraph. When hitting <Esc>, Vim
stops digraph entry and ends Insert mode or Command-line mode, just like
hitting an <Esc> out of digraph context. Use CTRL-V 155 to enter meta-ESC
(CSI).
If you accidentally typed an 'a' that should be an 'e', you will type 'a' <BS>
'e'. But that is a digraph, so you will not get what you want. To correct
this, you will have to type <BS> e again. To avoid this don't set the
'digraph' option and use CTRL-K to enter digraphs.
You may have problems using Vim with characters which have a value above 128.
For example: You insert ue (u-umlaut) and the editor echoes \334 in Insert
mode. After leaving the Insert mode everything is fine. On some Unix systems
this means you have to define the environment-variable LC_CTYPE. If you are
using csh, then put the following line in your .cshrc: >
setenv LC_CTYPE en_US.utf8
(or s