Author Topic: VSCode language extension for WinBatch  (Read 149 times)

cssyphus

  • Jr. Member
  • **
  • Posts: 55
  • Let's go Brandon
VSCode language extension for WinBatch
« on: October 16, 2021, 03:05:29 pm »
Casting no shade on the venerable WinBatch Studio IDE...

For those who use the Microsoft VSCode editor/IDE, here is a language extension for WBT files in VSCode. It took a while to cobble it together, and it's not quite perfect, but it works. Say hello to: code folding, multiple cursor editing, diffing files (i.e. "compare"), highlighting all instances of selected text, etc.

How To Install: installation is Very simple. 

1. Extract the zipfile and copy the included WBT folder (with all contents) to this location:
C:\Users\[your user account]\.vscode\extensions

2. Restart VSCode. Done.

The "not-quite perfect" part of this extension is that each capitalization option for each keyword is included, so the pop-up code-completion suggestions will include each of those - i.e. if you type "end" up will pop the suggestions endif, endIf, EndIf, ENDIF, endwhile, endWhile, EndWhile, ENDWHILE - really quite tedious, and basically rendering VSCode's quickSuggestions useless. Therefore, you might also want to disable code-completion-suggestions ("intellisense"?) for wbt files only by editing the settings.json file and adding this block:

Code: [Select]
    "[wbt]":{
        "editor.quickSuggestions": false,
        "editor.wordBasedSuggestions": false,
        "editor.acceptSuggestionOnEnter": "off",
    },

FWIW, the "meat" of the language extension is found in this file:
WBT\syntaxes\wbt.tmLanguage.json

That's where you'll find each keyword / operator / etc itemized and colorized.

If anyone takes this, runs with it, and improves it... it would be great if you could upload your revised extension here.
Is this a pandemic... or an IQ test? newz.icu

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: VSCode language extension for WinBatch
« Reply #1 on: October 16, 2021, 07:00:23 pm »
Nice Job.

Jim

stanl

  • Pundit
  • *****
  • Posts: 1572
Re: VSCode language extension for WinBatch
« Reply #2 on: October 17, 2021, 02:49:16 am »

cssyphus

  • Jr. Member
  • **
  • Posts: 55
  • Let's go Brandon
Re: VSCode language extension for WinBatch
« Reply #3 on: November 05, 2021, 08:30:12 am »
Uploaded version 2 of the VSCode WBT Language Extension

The big change is that the commands are now case insensitive, so the various capitalization options for each keyword are no longer expressly spelled-out. Therefore intellisense "quick-suggestions" will work correctly now.

Also, I discovered a few keywords that I had missed, so those have been included. The missing keywords were: fwdscan|backscan|to

IF ANYONE ELSE discovers keywords that were missed, please make note of them here so I can add them into the master for everyone else.

Next step: I'm looking at how to create a Shift+F1 context sensitive help capability that will open the Consolidated Help File at the desired function. Stay tuned for that.

Since this is pretty much a BUGFIX release, I've replaced the originally-uploaded wbt.zip attached to the OP with this new version. Installation instructions are as before - but I would advise deleting the old wbt folder (in ...\.vscode\extensions) before schlepping this one into its place. (If you wish to retain the old folder until you are confident this new one has no problems, MOVE it out of the extensions folder, do not simply rename it). And if, for any reason, you later wish a copy of the original wbt.zip, PM me and I'll email.
Is this a pandemic... or an IQ test? newz.icu

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: VSCode language extension for WinBatch
« Reply #4 on: November 05, 2021, 03:39:32 pm »
Works fine for me.  Thanks again.

Jim