0

If you have:

minimum
working
exampl[e]

with [] representing your cursor, and issue :.,-2y, Vim will tell you "Backwards range given" and prompt you to swap. If you don't swap it seems to cancel the command.

I'd like to understand the difference between :.,-2y and :-2,.y, as well as what happens when you say "no" to the prompt.

0

1 Answer 1

2

I'd like to understand the difference between :.,-2y and :-2,.y,

The former is simply wrong, because, as per :h E493,

A range should have the lower line number first. If this is not the case, Vim will ask you if it should swap the line numbers.

Although sensible, this actually deviates from POSIX, that says

It shall be an error if the first address is greater than the second address.


What happens when you say "no" to the prompt?

Nothing significant in this case. Read the source.

2

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.