Sublime Forum

How to use Visual Studio Code as editor?

#1

I’ve been trying to use Visual Studio Code as an editor for Sublime Merge. The syntax to open a file at a specific line for vscode would be:

/usr/local/bin/code --goto /path/to/file:5:1

Since, for unknown reason, Sublime Merge hide the editor argument format on macOS, I’ve tried to add it directly to Preferences.sublime-setting like so:

"editor_argument_format": "--goto \"${file}:${line}:${col}\"",
"editor_path": "/usr/local/bin/code",

However when I try to edit a file, it simply does nothing with no error message. Any idea how to get it working?

0 Likes

#2

Try the below ?

“editor_argument_format": "-g ${file}:${line}:${col}"

0 Likes

#3

I’m using:

	"editor_path": "/usr/bin/code",
	"editor_argument_format": "--goto ${file}:${line}:${col}",
0 Likes

#4

for Mac M1:

“editor_path”: “/usr/local/bin/code”,
“editor_argument_format”: “-g ${file}:${line}:${col}”,

0 Likes

#5

Does anyone know how to do the same thing for Windows?
There is a binary file C:\VSCode\bin\code in the VSCode folder.
But it runs, works and takes parameters only through the console.

0 Likes

#6

Did you try the above, replacing the path to the code executable with the windows specific one?

0 Likes

#7

Of course. But it doesn’t work. Even added extension to file code => code.exe and selected it in Sublime, it doesn’t work.
Tried to run the console with the path to the code file with the command
C:\Windows\System32\cmd.exe /c C:\VSCode\bin\code
doesn’t work either.

0 Likes

#8

The items in the bin directory are scripts; if you’re going to use one of those you should point it at the code.cmd instead of code, since code is a bash script. The code.exe file is inside of the install folder but not in bin, if you want to point it at that. Both worked for me in a simple test (right clicking, choosing open in editor from the menu).

0 Likes

#9

The code file bin folder is a bash script and thus probably not executed in case SM directly invokes it as executable or bash is not available.

I have VSCodium only, but all I need to do to is to point SM to the executable in installation directory.

grafik

0 Likes

#10

The way you have on the screen - it works, but only once. If I reopen Sublime Merge, it works again. Maybe it’s waiting for VSCode to close the file, but the --wait parameter I didn’t specify.
I have Portable VSCode

Upd:
Yep! Works only once, before Sublime Merge is rebooted. Tried setting Editor Wait Args => -r or --locale en-US to overwrite Sublime Merge’s built-in --wait, did not help.

Upd:
@OdatNurd Maybe there is some parameter for Editor Wait Args so that Sublime Merge doesn’t wait for the editor to close? After all, I don’t commit code, so I don’t have to wait for the editor to close.
Thanks

0 Likes

#11

Yep, seems to wait for it. As soon as I close VSCodium, the next file is opened.

Using c:\Program Files\VSCodium\bin\codium.cmd works for me, even though it’s rather slow.

0 Likes