Re: Usage of | character in digraphs

45 views
Skip to first unread message

Manas

unread,
May 27, 2020, 12:01:53 PM5/27/20
to v...@vim.org

Hi folks, I want to setup a few more digraphs according to my need. But while defining those I am running into error.

For example, I want to add ℕ (symbol for natural numbers set) as N| (N followed by the pipe character) but when defining the digraph as

: digraphs N| 8469

it is throwing E474.

Can I not use the pipe character while defining digraphs?

--
Manas
CSAM Undergraduate 2022

meine

unread,
May 27, 2020, 12:28:12 PM5/27/20
to vim...@googlegroups.com, v...@vim.org
On Wed, May 27, 2020 at 09:31:29PM +0530, Manas wrote:
> Hi folks, I want to setup a few more digraphs according to my need. But
> while defining those I am running into error.
>
> For example, I want to add (symbol for natural numbers set) as N| (N
> followed by the pipe character) but when defining the digraph as
>
> : digraphs N| 8469
>
> it is throwing E474.
>
> Can I not use the pipe character while defining digraphs?

maybe this page is of help, it uses a different digraph:

https://mullikine.github.io/posts/adding-new-digraphs-to-vim-and-evil/

however, it doesn't answer your question whether a pipe character is
allowed in defining a digraph...

//meine

Eli the Bearded

unread,
May 27, 2020, 12:37:05 PM5/27/20
to vim...@googlegroups.com
Manas <manas...@iiitd.ac.in> wrote:
> For example, I want to add ℕ (symbol for natural numbers set) as N| (N
> : digraphs N| 8469
> it is throwing E474.

The | character separates commands in ex-mode. You can use it in your
digraph, but you need to backslash escape it:

: digraphs N\| 8469

The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not
used often, and easy to overlook / forget.

Elijah

Manas

unread,
May 27, 2020, 12:41:29 PM5/27/20
to vim...@googlegroups.com, meine, v...@vim.org

maybe this page is of help, it uses a different digraph:

https://mullikine.github.io/posts/adding-new-digraphs-to-vim-and-evil/

I did look up this page but I wanted to use pipe character because when I actually write ℕ symbol on paper, I write N first then the horizontal line on it. By using pipe, I would remember easily what the digraph is.

Manas

unread,
May 27, 2020, 12:42:27 PM5/27/20
to vim...@googlegroups.com, Eli the Bearded
The | character separates commands in ex-mode. You can use it in your
digraph, but you need to backslash escape it:

  : digraphs N\| 8469

The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not
used often, and easy to overlook / forget.
Thanks a lot. That worked.

Tony Mechelynck

unread,
May 27, 2020, 12:46:56 PM5/27/20
to vim_use
On Wed, May 27, 2020 at 6:36 PM Eli the Bearded <v...@eli.users.panix.com> wrote:
>
> Manas <manas...@iiitd.ac.in> wrote:
> > For example, I want to add ℕ (symbol for natural numbers set) as N| (N
> > : digraphs N| 8469
> > it is throwing E474.
>
> The | character separates commands in ex-mode. You can use it in your
> digraph, but you need to backslash escape it:
>
> : digraphs N\| 8469

Indeed, I tried to see if I could (just as a test) define || as a
digraph for | and it took me several trials. With
:dig || char2nr('|')
I got the same answer as with :dig with no argument (a list of
existing digraphs). Then
:dig \|\| char2nr('|')
gave me E39: Number expected. Finally
:dig \|\| 124
gave me the expected digraph (and a subsequent :dig with no argument
listed it at the very end).
>
> The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not
> used often, and easy to overlook / forget.

I use it quite often, for instance to define an autocommand with a few
commands to be done in succession, or for an if..endif clause as {rhs}
to a mapping.

The fact that :digraph is not listed at :help :| implies that to
include a | in the operands of a :digraph command it must be
backslash-escaped.
>
> Elijah

Best regards,
Tony.

Tony Mechelynck

unread,
May 27, 2020, 1:35:06 PM5/27/20
to vim_use, meine, Vim mailing list
Instead of the external "unicode" program mentioned there, you could
also use the unicode.vim plugin by Christian Brabandt, available at
vim.org. After installing it,
:echo unicode#FindUnicodeBy('DOUBLE-STRUCK CAPITAL')
would give you a List of Dictionaries, one Dictionary for each letter
whose Unicode name contained that string, with all known properties of
that letter, including full Unicode name, hex and decimal codepoint,
digraph(s) if any, HTML entity/ies, and glyph. Of course, if you
wanted only the double-struck N, then
unicode#FindUnicodeBy('DOUBLE-STRUCK CAPITAL N') would give you just
that.

I use that plugin almost exclusively for its :UnicodeName command
(which gives the same information in a more user-friendly format for
the character under the cursor) but I know that it has other commands
and functions, and its help is in the outstanding Vim tradition.

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages