3

So I often use repeated invocations of gqip to re-wrap paragraphs of text or comments.

Unfortunately, the quickest way I've memorized for moving between paragraphs, }, lands me between them:

Qui⁁ut delectus ex enim. Qui doloremque suscipit itaque. Dolores assumenda commodi
laudantium eum ut sed. Facere voluptas omnis sunt assumenda quis.  Cupiditate aut
quidem corporis consequatur. Libero sed qui ea odio nisi.

Unde tempore suscipit et dolor unde nisi. Placeat asperiores sed rerum pariatur
nobis velit ea.  Doloremque impedit alias eligendi iusto sit in.  Eos commodi non
voluptates omnis sunt est.

Aliquami magni molestiae quo sit. Qui id eligendi minus esse provident.
Perspiciatis ut tenetur ad consequuntur vel aut ullam.

... gqip} ...

Qui ut delectus ex enim. Qui doloremque suscipit itaque. Dolores
assumenda commodi laudantium eum ut sed. Facere voluptas omnis sunt
assumenda quis.  Cupiditate aut quidem corporis consequatur. Libero
sed qui ea odio nisi.
⁁
Unde tempore suscipit et dolor unde nisi. Placeat asperiores sed rerum pariatur
nobis velit ea.  Doloremque impedit alias eligendi iusto sit in.  Eos commodi non
voluptates omnis sunt est.

Aliquami magni molestiae quo sit. Qui id eligendi minus esse provident.
Perspiciatis ut tenetur ad consequuntur vel aut ullam.

Now, I can use a non-text-object motion thereafter (gq}) to continue reformatting paragraphs; but that doesn't apply to every situation.

tl;dr Is there a way for me to preform motion by-paragraph, but end up on the first/last character of the paragraph object?

1
  • 1
    This isn't what you're asking, but if you use gqap instead of gqip it works even if the cursor is before the paragraph.
    – Mass
    Jan 18, 2018 at 0:57

1 Answer 1

1

So you just want to substitute something for } that moves down to the first non-empty line, i.e. the next paragraph? If I'm reading that right then...

It's just an extra character to do this, ), but if }) is more than you want to type:

:nnoremap } })

If you don't always want the new/modified movement you can add an alternate with the default movement:

:nnoremap \} }

Or leave the default movement alone and use \} (or whatever keys you want) for your modified movement.

(I'm using ) rather than, say, j so multiple empty lines between paragraphs are handled.)

2
  • I meant the opposite case — end up on the last line of the current (skipped-over-by-}) paragraph. Yeah, I suppose I could just map }k, but … I assumed that something like that might already exist? Hm. Jan 29, 2018 at 8:00
  • That explains why I didn't interpret your request the way you intended...motion-by-paragraph that remains in the same paragraph you start in wouldn't be motion at all. If neither native motion or text object works then a mapping is the way to go. Don't look at it as a hack...mappings are there for just such customizations.
    – B Layer
    Jan 29, 2018 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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