4

I am trying to enter a latin cross (, Unicode 271d) into a document. I can't find a pre-defined digraph for this. I am able to enter such a character with <ctrl-v>u271d or I can define a new digraph in my .vimrc like so: digraph \|- 10013.

But before I'd do that I'd like to know if there is really no pre-defined digraph for the latin cross. How can I verify this?

4 Answers 4

5

You can use the :digraphs command to get a list of all defined digraphs. This isn't very easy to search, but we can use :redir to store it to a file:

:redir all_digraphs
:digraphs
:redir END
:e all_digraphs

And we can now search the file:

/<C-v>u271d 

which gives us:

E385: search hit BOTTOM without match for: ✝

which confirms that this characters isn't a pre-defined digraph.

4

There is no such digraph defined by default. You can review available digraphs at :help digraph-table. The listing includes hex and decimal values as well as the name of the character, so you can easily search for an entry, for instance with :help digraph-table|/0x271d or :help digraph-table|/CROSS. The closest ones I see by value are

✓   OK  2713    10003   CHECK MARK
✗   XX  2717    10007   BALLOT X
✠   -X  2720    10016   MALTESE CROSS

and I suppose the closest one visually is

†   /-  2020    8224    DAGGER
2

I made the unicode plugin that helps with finding digraphs. You can use the command :Digraphs cross to search for a digraph whose name contains cross. Or when on the char, issue the command :Unicodename and it will output the digraph for that char. There are other similar commands as well, so check the help.

2

So... You want an easy way to determine if a character is already defined as a digraph in Vim?

The easiest way I know to do this is to place your cursor over the character in question and then type ga . At the bottom of the Vim window you'll not only see the character, its decimal value, its hexadecimal value, and its octal value, but if it's a defined digraph you'll also see the character-pair that defines the digraph.

To illustrate, try this:

  1. Copy this text and paste it into Vim: e è é ê ĕ ¿ ?
  2. In Vim, position your cursor over each of those characters and type: ga
  3. For e and ?, you should see a line at the bottom that lists its Unicode values in decimal, hexadecimal, and octal.
  4. But for the è é ê ĕ ¿ characters, you should also see a Digr value that tells you what character-pair defines the digraph.

For example, when I put my cursor over ? and press ga, I see:

<¿> 191, Hex 00bf, Oct 277, Digr ?I

That final Digr ?I means that if you type <C-K>?I while in INSERT mode, Vim will output a ¿ character.

Note that a character may have more than one digraph associated with it. For instance, the ¿ can by typed with both <C-K>?I and <C-K>~? but the output of ga will only show you one of them.


Let me try this out on the Latin Cross:

When I position my cursor on and type ga, I see this at the bottom of my Vim window:

<✝> 10013, Hex 271d, Octal 23435

Since there is no Digr text in that output, I can assume that the Latin Cross does not have a pre-defined digraph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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