Sublime Forum

How to add Syntax Highlighting?

#1

How to add syntax highlighting for a language not included?

Specifically I want powershell.

Assume I know nothing about how SublimeText works (because I don’t) that I can transfer to Sublime Merge. I’m only hoping that the syntax files that I know exist for SublimeText also work with sublime merge.

Also… are there docs somewhere for all the settings/options available? I’m seeing some really nice things in the forums, but have no idea how people find out how to do them.

1 Like

Change file type syntax
#2

Both .tmLanguage and .sublime-syntax files are supported in Sublime Merge. There is no plugin system in Sublime Merge at the current time, so packages have to be installed manually. You can go to https://packagecontrol.io and search for the package you’d like.

An example:

  1. Search https://packagecontrol.io
  2. Find https://packagecontrol.io/packages/PowerShell
  3. Click the Homepage link to go to https://github.com/SublimeText/PowerShell
  4. Download https://github.com/SublimeText/PowerShell/blob/master/Support/PowershellSyntax.tmLanguage
  5. Use the Preferences > Browse pages menu in Sublime Merge
  6. Create a folder named PowerShell and save the .tmLanguage file in there

If you had Sublime Text on your machine you could do:

  1. Open command palette and run “Install Package Control”
  2. Open command palette and type “Install Package”
  3. Type “PowerShell” and select the package

There is no reason you can’t use the evaluation of Sublime Text as a glorified package installer for now, if you don’t want to install packages manually.

Sublime Merge uses the same formats for creating menu entries, key bindings, command palette entries, syntax definitions, color schemes and themes as Sublime Text. You can find links to info about most of these at https://www.sublimetext.com/support.

7 Likes

Sublime Merge doesn't syntax-highlight Swift files
#3

Does that mean sublimeText and sublime merge share packages? Do I need to install them into the same folder then?

0 Likes

#4

Sublime Merge will load syntax definitions and settings related to syntax definitions from your Sublime Text install. It will only function if you install Sublime Text into the default location. It will not work if you use the portable version.

3 Likes

#5

and to clarify some more: anything you install into the Sublime Merge package folder will not be picked up by Sublime Text

3 Likes

#6

Is there a way to make it work with the portable version? Some configuration where I can point it to the right location? I’ve already setup editor_path, but that doesn’t seem to enable any deeper integration (aside from it being the external editor, obviously).

1 Like

#7

No, not currently. Integration with Sublime Text is one of the areas we will be improving with future development.

0 Likes

#8

I’m having difficulties understanding how exactly Sublime Merge picks up the packages/syntax highlight files etc. to use? Is it supposed to automatically use the same syntax highlight that I have active in Sublime Text? Or does it try to use syntax hilighting such that any user-added files in [some directory] will override the defaults? Does it pick up all the files in the packages directory? Does it need to have a specific name and/or be in a specific sub directory (like the example you posted above)?

I tried copying over my current *.tmTheme file for Java from Sublime Text, to basically every location I could think of inside the SM Packages directory, ie. in

  • Packages/Java.tmTheme
  • Packages/Java/Java.tmTheme
  • Packages/User/Java.tmTheme
  • Packages/User/Java/Java.tmTheme

but none of these actually do anything (I restarted SM after adding the file in each location). Is there something in the file SM requires for it to recognize it as valid for the given language? Or do I need to tell it the package/file(s) to use in the settings file?

And unrelated, is there a command or hotkey to switch between the side-by-side and the above/below diff views?

0 Likes