4

Not a dup of In Vim, what is the simplest way to join all lines in a file into a single line?, as I specifically mean to use the gq reformatting functionality.

I used to write latex in vim using 80 character textwidth. However, I've now switched to an infinite textwidth, so my lines go on forever.

Vim's reformatting (gqap for example), combines a few lines into a paragraph, wrapping them at 80 characters. I'd like it to instead combine them into a single line.

ie

Without a \clang{goto} statement in the HIR, we must instead use conditional
statements to check the iteration number.

should reformat into

Without a \clang{goto} statement in the HIR, we must instead use conditional statements to check the iteration number.

when it is highlighted and gq is pressed.

Community
  • 1
  • 1
Paul Biggar
  • 27,579
  • 21
  • 99
  • 152

2 Answers2

4

If you don't like "J" as depesz suggested then do

:set tw=9999

Then do 'gq'. Adjust tw to your needs.

Maxim Kim
  • 6,192
  • 2
  • 29
  • 28
3

Why don't you just "J" the lines after you select them?

  • J as in join, to make it memorable – Christian Sep 20 '09 at 13:04
  • My fingers are used to gqap (and other forms of gc). I don't want to have one command for latex and another for other forms of editing. – Paul Biggar Sep 20 '09 at 13:24
  • @Paul: sorry, but this argument doesn't make sense. If you know command "cp" you shouldn't use "mv"? If you're used to hammer, you'll prefer it to screwdriver when you'll need to use a screw? –  Sep 20 '09 at 15:36
  • 1
    @depesz: I'm trying to figure out why gq isnt working the way I thought it should. gq is the reformat command. Just because this particular reformat is similar to joining doesnt mean I should start using J. Your analogy makes no sense. FYI, J doesnt work in some cases, such as in the middle of 3 lines, which I would expect gqap to (with the appropriate settings). – Paul Biggar Sep 20 '09 at 17:43
  • 'vapJ' (or maybe 'vipJ') should be the same as 'gqap' with 'set tw=9999' – Maxim Kim Sep 21 '09 at 04:51