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?

2 Likes

#2

Try the below ?

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

1 Like

#3

I’m using:

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

#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

#12

Hi,
I tried every solution above and nothing works for me. I am using M1 MAC Monterey, can some one share his settings ?
This is what i tried
This is what i tried

1 Like

#13

Hi, this is what I have and it works for me:

0 Likes

#14

Mates, how to go back from VSCode into beloved smerge?

I sometimes need to live in VSCode, but missing Sublime Merge friendly integration.

In Sublime Text, I just click the bottom status line with repo name & diffs counter as a link, and voila - I am in Sublime Merge. How to make something like that + hotkey in VSCode to quickly jump to commit/check current file & repo in SMerge?

0 Likes

#15

ah, right:


though now to decide which is better. Hick. :man_shrugging:

UPDATE: self-answer: stopped with Giovanni Derks’ one:
https://marketplace.visualstudio.com/items?itemName=giovdk21.vscode-sublime-merge

0 Likes

#16

For Mac users, pay attention to the Editor Path. I was using the […] to select the path to VSCode under Applications. This seemed to work, and invoked and focuses on VSCode…but ignores the file/line/col args.

Typing in /usr/local/bin/code (as recommended throughout this thread) worked like a charm.

1 Like

#17

First, make sure the file you are trying to open actually exists. If you’re exploring a commit that’s not on your branch, the file may not exist.

Then, clear the Editor path and arguments fields to reset them to default.

Then go to Preferences, edit settings. This will open the config file.

Then you can set i.e. for Windows

	"editor_path": "code.cmd",
"editor_argument_format": "-g ${file}:${line}:${col}",
0 Likes

#18

Thanks I had missed that detail and that was my issue.

0 Likes