vimtricks.wiki Concise Vim tricks, one at a time.

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 digraph is 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 a then ` (backtick) then <BS> → produces à
  • The digraph table is the same as the one used by <C-k> — use :digraphs to 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 digraph is 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 nodigraph when not needed
  • Use :digraphs to 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

Next

How do I control how many lines Ctrl-U and Ctrl-D scroll?