Wednesday, May 27, 2020

Re: Usage of | character in digraphs

On Wed, May 27, 2020 at 6:36 PM Eli the Bearded <vim@eli.users.panix.com> wrote:
>
> Manas <manas18244@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.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXt0Dm2NHDVmjL3hLfB9iVDeOtugvqLS6%3D3aA7oHDCxRhA%40mail.gmail.com.

No comments:

Post a Comment