I am trying to write my PhD thesis in vim using LaTeX
So the documents will have two distinct types of content - markups that are relatively short, and paragraph text that is rather long.
\begin{some environment}
Long content here (Lorem ipsum dolor ......
.........
\end{end enviroment}
Since the drafts will involve a lot of edits, in order to keep my writing comprehensible for the text, I had set an autocmd to set formatoptions=at and textwidth=110 based on filetype=tex so that vim shall insert linebreaks appropriately and reformat documents on the fly upon delete/edit cycles.
The problem is that these reformats happen for the markup text also. For example, if I edit just the markup, the autoformatting kicks in, realigning linebreaks to satisfy the textwidth setting. Similarly, comment lines are also mangled up by the on-the-fly reformatting.
How do I set up the formatoptions in my vimrc in such a way that these autocommands fire only for long paragraphs and leaves short texts and comments unchanged.
set textwidth=0andset wrap. If you insist on hardwrapping, I would recommend to usetextwidth=80(or smaller) to make sure that the content fits in standard terminals. – Karl Yngve Lervåg Apr 02 '18 at 19:06parto wrap only long lines usinggq. But this is a manual process. Can this be triggered in insert mode automatically with vimtex? – Dr Krishnakumar Gopalakrishnan Apr 02 '18 at 19:37let g:vimtex_format_enabled = 1, then you can get an improved formatter withgqfor LaTeX and manually format paragraphs with e.g.gqip.Note: All of this is clearly very subjective, and even though I propose some personal opinions, you are of course allowed to do whatever you want! But I do think
– Karl Yngve Lervåg Apr 06 '18 at 05:58textwidth=80(or smaller) is good advice, as well as what I've written about diff-friendly styles.