n-t-roff / heirloom-ex-vi

The Traditional Vi (vi with many enhancements from Gunnar Ritter)
Other
67 stars 15 forks source link

Consistent with vim, but still a little inconsistent I think #2

Closed larryhynes closed 7 years ago

larryhynes commented 7 years ago

Hi

In a test file:


foo
bar
baz

foo1
bar1
baz1

1G"ay}G"ap yields:


foo
bar
baz

foo1
bar1
baz1

foo
bar
baz

but 1G}"ay}G"ap yields:


foo
bar
baz

foo1
bar1
b
foo1
bar1
baz1az1

vim behaves the same, (n)vi on OpenBSD does not (OpenBSDs vi returns the same output as the first example, which is what I would expect vi to do).

This is either an inconsistency in vi, or a fault in my expectations! :smile:

n-t-roff commented 7 years ago

Like vim, nvi had been written from scratch. Whereas vim tries to be as compatible as possible--even for "bugs" (not in any case--there are details which differ from vi), nvi likely tries to be a better or "always correct" vi (although Wikipedia describes it as "bug for bug" compatible with vi too). Note that vim predates nvi. Or maybe Keith just had not been aware of this issue. So I agree, there is an inconsistency between vi and nvi here, but I'd prefer to declare it as a "feature" rather than fixing it ;)

larryhynes commented 7 years ago

Well, leaving vim and nvi aside, I think heirloom vi's behaviour here could be improved or - dare I say it? - fixed! So, that would be my vote, if such a thing mattered. ;^)

n-t-roff commented 7 years ago

Ok, if nobody else disagrees I'll work on that. (Busy with other projects I can't address it in the short term, unfortunately.)

This bug is in every original vi version which support these commands, so heirloom-vi will then be incompatible here. Nevertheless it is a bug reasonable to be fixed (i.e. the current "feature" in vi and vim is IMHO not of any use).

n-t-roff commented 7 years ago

Bad news on this--I'm quite sure that the bug is in nvi, not in vi and vim. If a paste works line-wise or character-wise depends on the last character of the yank buffer. If it is a newline the the paste is line-wise, else character-wise. You can test that--if you start a "ay} yank in the middle of a paragraph the paste will be character-wise, since in this case no new-line is appended (use :registers in vim). This is also the case for the last paragraph which does not end with a new-line. Hence nvi behaves wrong here ;)

larryhynes commented 7 years ago

That makes a lot of sense, thanks for taking the time to look into it and for clarifying it.