0
  1. To hard-wrap a single line, we can use gqq,
  2. and to hard-wrap multiple lines, we can select them in visual mode and then use the same gqq command.

However, I suppose that there is probably a smarter way to accompany the second task. Does it really exist?

So the following code

// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
// b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b

should be hard-wrapped to

// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
// a a a a a a a a a a a a a a b b b b b b b b b b b b b b b b b b b b b b b b
// b b b b b b b b b b b b b b b b b b b b b b b b b b b b
0
2

Since gq is an operator, it accepts motions and text-objects. My go-to is gqip in cases like this. With plugins you can often make things like gqgc (format a comment) or gqii (format this indented block) work, since the text-objects orthogonally extend all operators.

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.