I have a LaTeX file opened in Vim. While paragraph formatting using gq} command, it wraps the comment line also. I am using a recent installation of Windows Subsystem for Linux and Ubuntu 24.04 and Vim 9.1 with all default settings.
My file:
\section{one} % %This is comment % This is my text in multiple lines. After gq}, it is giving an output as below
\section{one} % %This is comment % This is my text in multiple lines. However, I want the comment not to be wrapped. The desired output is
\section{one} % %This is comment % This is my text in multiple lines. I have tried several things like setting text width, nowrap, syntax off, etc. Kindly help with setting that will work in Vim. Interestingly, another machine (Redhat 8.4 and Vim 8.0) and the Vim formatting is working as desired.
:help gq? Please edit to include the values of the options mentioned there, i.e.'formatexpr','formatprg'and'formatoptions'. Thank you. I guess the answer will be to:set formatoptionswith something from:help fo-table.vim --cleanwith:set filetype=latex. I get your desired output. You may want to double-check filetype detection is on and works correctly. Anyway, we'll likely need more information to reproduce your issue.formatexpr=is blank,formatprg=is also blank,formatoptions=tcq. Tried:help gqbut is bit complex to me. File type default was plaintex and is changed to latex. Still, the problem persists. By the way; this is a recent installation on Windows (WSL) Ubuntu 24.04 and VIM91. All default settings. Interestingly, I checked in another machine (redhat 8.4 and vim80) and the vim formatting is working as desired.vim -u NONE -U NONE -N file.texsolves the problem temporarily. However, needs to find out which configuration/plugin is causing the behavior.