37

How do I enter Unicode characters like 𝓭 without copying it to the clipboard and pasting it?

Things I know:

  • The command ga on the character 𝓭 gives me hex:0001d4ed.
  • I can copy it on the clipboard and paste it via "+p.
  • I know how to enter Unicode values that have a 4 digit hex code:
    <C-v>u for example <C-v>u03b1 gives the α character.
2
  • 1
    There are no unicode codepoints that require 8 hex digits. 6 is the maximum as 0x10ffff is the maximum codepoint. Feb 2, 2012 at 20:48
  • 3
    +1 for the "ga" command!
    – Sabuncu
    Dec 10, 2013 at 18:30

3 Answers 3

50

You can use <C-v>U, that is, an uppercase u, to input an 8 digit hex codepoint character.

More information here and here.

1
  • 1
    you're so fast - I can't accept it yet. ;-) thank you - I completely overread the <C-v>U in the first link you gave me, when I read it first. Feb 2, 2012 at 20:54
11

There is a Vim feature designed to simplify entering characters that cannot be typed directly. It is called Digraphs (see :help digraphs).

To define a custom digraph for entering ‘𝓭’, use an Ex command similar to the one below.

:dig dd 120045

where 120045 is the decimal representation of ‘𝓭’, as one can easily confirm using the ga command.

Inserting a character using a digraph is simple: Type Ctrl+K followed by the shortcut of that digraph (dd for the above example).

2
  • defining a global digraph - sounds a bit overkill to me I only have to insert the character once or twice and then have a imap <buffer> \curld 𝓭 in a tex-plugin to use it just with latex - in other places I don't need it and digraphs I can enter via the keyboard-compose key (I use the neo-keyboard-layout). Feb 3, 2012 at 11:35
  • @epsilonhalbe: Yeah, that is a fine approach, too.
    – ib.
    Feb 21, 2020 at 2:41
6

There exists a Unicode plugin for Vim. According to the plugin description, this plugin has three main features:

  1. Character/digraph completion using either the Unicode name or the codepoint.
  2. Identify the character/digraph under the cursor.
  3. Search for digraphs by name; transform two normal characters into their corresponding digraph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.