skip to Main Content

For… some-odd years now, I have repeatedly mispelled the word "local". The most common mistake for me is "lcoal".

Is there a trick, a tip, a plugin for VSCode that would see a specific word I give it (lcoal) and immediately replace with "local"? I use this as a scope (local.x) constantly in my language of choice.

I don’t want a "bad underline", or syntax throw up, or even an alert. I just want VSCode to replace it immediately. I don’t want to have to search and replace. And this language doesn’t have any kind of pre-processor before running.

Is there anything like that? My Googling and searching extensions didn’t turn up anything useful.

(I think I was able to do this in Sublime before I ever switched to VSCode.) And yes, I should just learn to spell it correctly. I get that. And 99% of the time I do, but that 1% is a killer for me.

3

Answers


  1. Have you tried the Auto correct Extension.

    Extension inside VSCode

    I tried it out and it works for your usecase. The only pain is that you have to setup the words manually in your settings.json file if they are not in the useLargeList that is deactivated per default.

    Go to:

    File/Code -> Preferences -> Settings -> User:Extensions:Auto Correct Configuration -> Edit in settings.json

    User:Extension:Auto Correct Configuration

    Paste the following configuration or add the "auto-correct.dictionary" entry, save and restart

    {
        "auto-correct.dictionary": [
            {
                "languages": [
                    "*"
                ],
                "words": {
                    "lcoal": "local"
                },
                "useLargeList": true
            },
        ]
    }
         
    

    sample settings.json

    Now lcoal will be automatically changed to local

    lcoal gets automatically transformed to local gif animation

    Login or Signup to reply.
  2. Navigate to search icon then press cont + shift + h then enter search term and replace term.. now you can easily find all occurrence of your word and replace them easily

    Login or Signup to reply.
  3. Another possibility is the HyperSnips extension. It is fairly easy to set up. Remember to HyperSnips: Reload Snippets if you make any changes.

    You would make a "snippet" like this, in your <language>.hsnips file:

    snippet `(lcoal)` "replace lcoal with local." A
    ``rv='local.'``
    endsnippet
    

    The A at the end makes it "automatic" – you could add the . to snippet prefix if you wish – so that it is not triggered until you type the .:

    snippet `(lcoal.)` "replace lcoal. with local." A
    ``rv='local.'``
    endsnippet
    

    HyperSNips mispelling demo

    This:

    snippet `(lc)` "replace lc with local." A
    ``rv='local.'``
    endsnippet
    

    automatically replaces lc => local.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search