visual-studio-codespell-checkingshebang

Disable Spell Check for Shebang in Visual Studio Code


With Python primarily being used in virtual environments now, my shebang lines for python scripts can vary depending on the location of the particular virtual environment I'm working in.

This causes the spell check in Visual Studio Code to flag words in the shebang line. I can disable spell check for lines further down in the document by adding the comment # cSpell:disable but this doesn't help with the shebang line because it has to be the first line in the document.

In this example, cybersimon and samsungtv are flagged by the spell checker:

#!/home/cybersimon/git/samsungtv/bin/python
# cSpell:disable

import ssl
import argparse

I could add custom words to the dictionary, but that will require adding every directory of every python virtual environment I have, which doesn't seem like a good solution, especially as the number of environments grow.

I could disable spell check for all python files. But this would require all python files to have a .py extension. There a cases when I am creating commands and don't want to use a .py extension, hence the use of the shebang.

Any assistance is greatly appreciated!


Solution

  • Check if an "Ignore Reg Exp" is enough:

    /^#!.*$/g
    

    Ignore Reg Exp for Cspell