How do I enable an alternative digraph entry mode where I type two characters then backspace?
Answer
:set digraph
Explanation
With :set digraph enabled, you can enter special characters in insert mode by typing the two-character digraph code followed by <BS> (backspace). Vim detects the sequence and replaces both characters with the corresponding special symbol. This is an alternative to the more common <C-k>{char1}{char2} digraph insertion method.
How it works
- When
digraphis set, Vim watches for sequences of two printable characters followed by a<BS>in insert mode - If the pair matches a digraph, both characters and the backspace are replaced with the special character
- For example: type
athen`(backtick) then<BS>→ producesà - The digraph table is the same as the one used by
<C-k>— use:digraphsto list all available codes
Example
With :set digraph active in insert mode:
Type: e ' <BS> → results in: é
Type: A E <BS> → results in: Æ
Type: 1 2 <BS> → results in: ½
The equivalent with Ctrl-K: <C-k>e' → é, <C-k>AE → Æ
Tips
:set digraphis session-only; add it to your vimrc to make it permanent- It can interfere with intentional backspace usage on two-character sequences — toggle it off with
:set nodigraphwhen not needed - Use
:digraphsto see the full table, or:digraphs |to filter for a category - The
<C-k>method works regardless of this setting and is often preferred when digraphs are needed infrequently