Sublime Forum

Xcode as Editor


When configuring the editor is it possible have Xcode be the editor of choice? I have tried to set the editor path to /Applications/ (which did nothing) and /usr/bin/xed (which will open Xcode but only with the previously opened file). Any other way to make this work? Thanks.



I think the issue you have is that xed can be given a filename and will open that filename in Xcode, but if you provide it the name of a file that doesn’t exist you need to specify -c or --create to tell it to create the file first; otherwise it just ignores the file name you gave it and opens Xcode, which natively seems to just re-open whatever you had open last.

It isn’t immediately apparent that this is the issue because for some reason the preferences Dialog on MacOS doesn’t include a key preference that appears on Linux and Windows:


The Editor Argument Format specifies the command line that is added to the editor to open the correct file. The value seen in the screen shot is the default value, which creates a filename that xed can’t open because it has line and column information in it.

If you hand edit the preferences file via Preferences > Edit Settings (though you probably have to revert the Editor Path back to the default temporarily) you can add the setting in manually there:

    "editor_argument_format": "${file}",

As seen in the image you should also be able to use ${file} --line ${line} (or possibly reversed as --line ${line} ${file} if xed is sensitive to the order of arguments) as the value for this setting to get it to open the file and also focus the appropriate line.

Anecdotally, the first form did not work for me at all (it would not open the file) and the second one opens the file but doesn’t put the cursor on the correct line. However --create also does nothing for me either, so the two may be related. The last time I used XCode was 2012 which predates some MacOS upgrades so there may be some weirdness going on there. Setting the setting to just ${file} works for me, though.



Thank you for the great reply! Like you I was able to get ${file} to work but was having problems with --line ${line} ${file} (the file will open but not select the supplied line number) even though that should be working according to man xed.

It’s interesting to note that even trying to run xed via Terminal throws an error when supplying a line number:

[~]: xed --line 1 example.swift
2019-07-26 20:34:58.946 xed[45223:3819316] Error: Error Domain=NSOSStatusErrorDomain Code=-1719 "errAEIllegalIndex: index is out of range in a put operation " UserInfo={ErrorNumber=-1719, ErrorOffendingObject=<SBObject @0x7fa366d734b0: <class 'souf'> -1 of application "Xcode" (45089)>}

In the above example the file example.swift had 26 lines, but still threw that error whenever trying to jump to any line number. Seems to be a problem with the latest version of xed (i.e. 10.3). :man_shrugging:

1 Like