How to configure external script editor?

Hi,

When I try to edit a JScript or VBScript script from Preferences > Toolbars > Scripts via the Edit button shown on top, Directory Opus launches Notepad++ as the external editor even though I have Visual Studio Code associated with those kind of file types.

This doesn’t happen when I double click in a Lister on those kind of files or choose the Open option from their respective context menus. In these situations, the script files are opened in Visual Studio Code as expected.

In addition, I’ve checked the Registry file associations for .js and .vbs file types —User Choice, System, and Current User entries— and no one of them is currently pointing to Notepad++ as the program associated with them (via the open verb).

Is there any option in Preferences to set an external script editor that I am missing? I used to use Notepad++ as my code editor in the past, but I can’t remember having set an option to use it in Directory Opus as the script editor. I can’t find any option in the Preferences about that. Any ideas?

If a script is a standalone file (rather than a script package), clicking the Edit button will open it in your default text editor.

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Prefs/Scripts.htm

This can be changed in the Windows settings, e.g.

1 Like

Thank you, now I understand. It is using the application associated to .txt files instead and that is Notepad++ in my case.

If you ask me, Directory Opus should respect the associations for these file types or allow us to specify an external editor for scripts in the configuration. This could be a (minor) feature request.

Might be a design choice to avoid .js files getting run by a scripting engine.

You can also open the scripts folder and launch the file from there.

You’re right about that. I didn’t consider that side effect of respecting the user’s associations for script file types.

Opening the scripts folder and launching the editor from there is ok, but I’d rather have something like a script_editor_path advanced option under Filesystem here:

2 Likes

I think the text viewer/editor setting under Preferences / File Operations / Double-click on Files will be used it one is defined there.

Unfortunately, that setting just does what it claims: it opens unregistered file types in the text viewer I have specified, Visual Studio Code, if they appear to be plain text — I didn’t know about this option and I find it useful, too, by the way :grinning:. Directory Opus keeps using the program associated to .txt files to edit scripts from Preferences > Toolbars > Scripts.

What extension do your scripts have? Opus has an option to use .txt to make it easier to share them (since the forum and most antivirus don't like uploading/downloading .js and .vbs files), but it can be turned off and existing scripts can be renamed.

My scripts have .js and .vbs file extensions.

It should use the Edit verb on those types, I think.

Although we are planning to add a dedicated script editor setting as well.

2 Likes

This is the right answer. I have added the verb edit to the Registry and now .js and .vbs files are opened with the program specified as the command for that verb (which in my case is Visual Studio Code). Before this the only verb registered was open.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.js\shell\edit]
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.js\shell\edit\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.vbs\shell\edit]
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.vbs\shell\edit\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

That would be a nice addition. Thank you.

1 Like

VSCode should not have taken over the Open verb on .js or .vbs files as that would break being able to run them. (Assuming VSCode itself did that.)

You are right, VSCode didn’t do that, it was me. VSCode just adds a context menu entry for all file types — which I don’t like at all, by the way, but fortunately Directory Opus excels in allowing us the users to reign over file context menus — with the following Registry entry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\VSCode]
@="Open w&ith Code"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

The thing is, these days, when it comes to scripting, I'm more of a PowerShell scripting guy, so I've disabled the ability to run JScript (.js) and VBScript (.vbs) scripts by double-clicking on those files on Windows. I don’t want to be able to run them by accident. I did this by choosing VSCode as the default program to open these file types.

As I guess you already know, when you do this, Windows associates certain ProgIDs defined by VSCode for these supported file types to their respective file extensions… and these ProgIDs have only registered the standard open verb:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.js\shell\open]
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.js\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.vbs\shell\open]
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VSCode.vbs\shell\open\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

That’s the reason why Directory Opus could not find the edit verb for .js and .vbs file types and fell back to the application associated to plain text (.txt) files in order to edit scripts from Preferences > Toolbars > Scripts. Once I added manually the edit verb entries to the Registry where they were needed it worked.

Makes sense, although I’d be weary of it breaking something that relies on it being the default action during installs and similar. (Not sure if any/many things do, but they might.)

Setting a double-click event for the types in Opus would let you override double-clicks in Opus without affecting anything else, which could be a good solution (but won’t help if you double-click a script somewhere else, like the Windows desktop). The mouse events are specific to Opus so you don’t need to worry about them changing what happens system-wide.

Would that mean, with full (external) debugging or just with editing capabilities?

Just editing.

Thanks, had some hope that programming DO gets a little bit more convenient :wink: