1

So I'm reading the ex spec and came across the following section under Command Line Parsing in ex:

  1. Otherwise:

    a. If the command was a map, unmap, abbreviate, or unabbreviate command, characters up to the first non-<control>-V-escaped <newline>, <vertical-line>, or double-quote character shall be skipped and be part of the command.

    b. Otherwise, characters up to the first non-<backslash>-escaped <newline>, <vertical-line>, or double-quote character shall be skipped and be part of the command.

    c. If the command was an append, change, or insert command, and the step 12.b. ended at a <vertical-line> character, any subsequent characters, up to the next non-<backslash>-escaped <newline> shall be used as input text to the command.

...

To me, this meant that the command

:i | quit

would insert the word "quit" instead of potentially exiting when I exit text input mode. Is this a bug or am I misreading the spec?

The ex command on my machine is symlinked to vim (version 8.2)

2
  • I would tend to agree with your interpretation but I would find the described behavior weird.
    – romainl
    Commented Jan 21 at 11:19
  • I guess it would be weird considering similar functionality with other apps like here docs. It felt strange to me since I originally expected the command and text to be on the same line. ie having :i here insert the a line containing "here" instead of throwing an error Commented Jan 21 at 21:15

1 Answer 1

0

After studying the spec, I think i found clarity

Append

  Historically, any text following a <vertical-line> command
  separator after an append, change, or insert command became part
  of the insert text. For example, in the command:

      :g/pattern/append|stuff1

  a line containing the text "stuff1" would be appended to each
  line matching pattern.

So it seems pretty clear how the "|" should be handled and it seems like my ex implementation (vim) is buggy. Contrary to my initial thought, the command would still have to be ended with .\n

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.