I have a few documents that result in a lot of warnings because I've been using $...$ instead of \(...\) and a few other tiny details.

How can I automatically fix these chktex warnings? vscode provides a "quick fix" but I would need to manually apply in each case.


I was wondering if there is some command line tool (or similar) that can automatically fix these warnings. vscode can fix warnings one by one automatically, but that is too time consuming.


Here is the code:


Here is the minimum command line that vscode executes:

chktex -wall example.tex 

and the output:

ChkTeX v1.7.6 - Copyright 1995-96 Jens T. Berger Thielemann. 
Compiled with POSIX extended regex support. 
Warning 46 in example.tex line 3: Use \( ... \) instead of $ ... $.
No errors printed; One warning printed; No user suppressed warnings; No line suppressed warnings. 
See the manual for how to suppress some or all of these warnings/errors.
  • Please provide a minimum working example of a LaTeX document that the $-related warning messages. For sure, on MacTeX2018, passing \documentclass{article} \begin{document} $1+1=2$ \end{document} thru chktex does not generate any $-related warning messages.
    – Mico
    Feb 2, 2019 at 20:34
  • 6
    there is nothing wrong with using $ but if you want to change to \( any text editor should allow you to replace $...$ by \(...\) using regular expression search.replace Feb 2, 2019 at 20:34
  • 1
    There's also debuck by Loop Space, which performs this replacement. Feb 2, 2019 at 23:35
  • 2
    Just FYI, I don't recommend running with -wall, there are some weird warnings that almost no-one would actually want, such as warning about comments. This warning (about $) is off by default because it's not as important as others. That said, ChkTeX doesn't provide automatic fixing. Feb 13, 2019 at 3:31

2 Answers 2


You can accomplish this in vscode by doing a find-replace with a regex:

Press Ctrl + Shift + h (or use the menu bar Edit > Replace in Files)
In the search field enter this regex:
Make sure the "Use Regular Expression" button is checked (Alt + r)
In the replace field enter:
files to include:

Click the "Replace All" button (Ctrl + Alt + Enter)
and watch the magic happen

  • 1
    Just as a note, for those that are using $$a$$ instead of \[a\], you should replace \$\$([^$]+)\$\$ with \[$1\] first.
    – Lynnx
    Mar 9, 2022 at 6:43

This message is number 46 warning of ChkTex,just append -n46 to construct the compile command, which means ignoring the number 46 warning. As illustrated below(It's an option in VSCode extensions setting).VSCode Extensions SettingMore detail in the document of ChkTex ChkTex.dvi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .