0

I have remapped } as follows noremap } }jz. so that as I go down paragraphs the cursor stays in the middle of the screen and to the first line of the next paragraph (usually).

That works fine. But I also use } after y to yank say the next 3 paragraphs to paste elsewhere. For example y3}. In this usage, I want Vim to ignore my mapping. (The rationale is that after a y there is no movement, so my modification to the movement should also be ignored after a y.)

Is there a way to map a movement key, but have a mapping be ignored after y, d, and perhaps even after number prefixes such as 2.

3

Use nnoremap instead of noremap. Mode after pressing y is Operator-pending and that could be addressed by onoremap. You can read more about modes in :h map-modes.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.