4

I have column-oriented text of the form:

TR #  DATE        DESCRIPTION                  PROGRAMMER
----- ----------- ---------------------------  -----------
12345 01-APR-2014 This is an April Fool's      Joe Sewell
                  joke. Not!

Now I want to widen the DESCRIPTION column and rewrap that column only to the new width. Let's say, for the sake of this question, I would add the spaces myself so it would look more like this:

TR #  DATE        DESCRIPTION                        PROGRAMMER
----- ----------- ---------------------------------  -----------
12345 01-APR-2014 This is an April Fool's            Joe Sewell
                  joke. Not!

Now comes the bit I need help on. I want to perform a visual block selection (CTRL-V or CTRL-Q in gvim) on the DESCRIPTION column and perform an ex command or mapping to rewrap the text to the selected width, producing:

TR #  DATE        DESCRIPTION                        PROGRAMMER
----- ----------- ---------------------------------  -----------
12345 01-APR-2014 This is an April Fool's joke.      Joe Sewell
                  Not!

I can deal with the subsequent lines having trailing spaces, if necessary. I want none of the rest of the text on the selected lines affected. (Those familiar with EVE under OpenVMS, this is equivalent to block selecting a chunk of text and, with the EDT keypad, typing GOLD-8.) I don't want indentation changed.

2 Answers 2

4

My FormatToWidth plugin provides a <Leader>gq command with which you can achieve this: enter image description here

0
2

Have you considered moving the DESCRIPTION column to another buffer, setting your desired textwidth for that buffer (:set textwidth=yournumber), formatting with gq, then moving back to the original location?

2
  • I thought about that, though I'd have to derive textwidth based on the width of the selection (since it's not always consistent). I was hoping for something a little easier, but I might be able to automate that.
    – Joe Sewell
    Apr 8, 2014 at 17:31
  • I was also hoping for a way to do this without having a new buffer appear & disappear from the screen.
    – Joe Sewell
    Apr 10, 2014 at 18:22

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.