Vim/neovim's automatic line wrapping feature is great for writing reports in Markdown, but sometimes it kicks in when I don't want it to. Is there a setting somewhere that I can set a regex pattern to disable line wrapping within specific blocks of text? My specific use case is to disable text wrapping within inline LaTeX math blocks so they don't end up spanning multiple lines even if the equation contains spaces.
Example
Before autoformat:
Some really long line of text containing an equation $E = mc^2$, with textwidth set to 56 so that the line will wrap in the middle of the equation.
What I get:
Some really long line of text containing an equation $E
= mc^2$, with textwidth set to 56 so that the line will
wrap in the middle of the equation.
What I want:
Some really long line of text containing an equation
$E = mc^2$, with textwidth set to 56 so that the line
will wrap in the middle of the equation.
Related
This post shows how to disable Markdown syntax highlighting within LaTeX math blocks, but the inline math syntax pattern only works for inline math expressions that don't contain a line break. I'd like to disable text wrapping within inline math partly for legibility reasons and partly so that syntax highlighting doesn't break for equations that happen to be at the end of a line.