5

When I am editing a LaTeX file using Vim-LaTeX and want to reformat a section of text that is in a \caption{} I get overhangs or underhangs - I am not sure what to call them. I first select the text in the caption then use "gq" to reformat it. After reformatting the caption looks like:

    \caption{The problem is that when I reformat the text
         in a caption the text on each successive line
      begins further and further to the left until it begins 
   at the first space of the line.}

what I would hope the result would look like would be something like:

    \caption{The problem is that when I reformat the text
         in a caption the text on each successive line
         begins further and further to the left until it 
         begins at the first space of the line.}

I hope the formatting in this post remains true to what I typed in, but I tried to describe the problem in the first example caption. The second should be left justified.

Does anyone know what I need to do to fix this? I am assuming that there is a setting that I need to change, but I have not been able to figure out what it is.

sudo bangbang
  • 27,127
  • 11
  • 75
  • 77
Shawn
  • 179
  • 1
  • 15

1 Answers1

1

The gq command formats based on 'formatexpr' or 'formatprg'. You can start by checking the values of these options with :se fex? and :se fp?.

From looking through the vim-latex plugin it never sets these options, so this is likely set by your other plugins or vimrc. You can find out exactly where an option is set by using :verbose.

Conner
  • 30,144
  • 8
  • 52
  • 73
  • first a late thanks, I would upvote but apparently neither `'formatexpr'` or `'formatprg'` are set in my setup, so that doesn't help - yet. A follow-up question that might move this forward. I have found that if the text is moved so that it isn't on the same line as either {}, then it formats properly - unfortunately I don't know how to clarify by providing a good example here. But if I change from `\caption{some text}` to `\caption{` - then I put, `"some text"` on a new line, then on yet another line I put `}`. I can select the text and `gq` will properly format. – Shawn Feb 10 '21 at 23:19