Using Sublime Text 2 with Unity3D – Part 1

Update: These files are outdated please install them from package control instead. See this post for details.

I think sublimetext 2 is currently the best text editor available. I have been using it for awhile now and really love it. I thought I would share some smalls additions I have made to make it easier to use while working with Unity3D.

Here is a link to my C# language file which adds all the Unity keywords, built-in functions, and types for syntax highlighting. It also adds function name highlighting but, but its not perfect and some “else if” statements may be highlighted slightly incorrectly. C#.tmLanguage

Update: For JavaScript highlighting here is a language file. JavaScript.tmLanguage

Also here is a port of my color scheme Candy Mountain for SublimeText 2. Candy Mountain

Screen Shot:

About The Author

19 Comments

  1. Amey says:

    Thanks, this’ll prove useful. Just recently switched to Sublime Text 2 myself, thought I’d look around for a plugin for Unity, and stumbled across your post!

  2. Damien says:

    Beautiful, thanks for doing the language file!

  3. James says:

    How do you install new syntax definitions? I can’t find anywhere that explains it?

    • Jacob says:

      It depends on what platform you are using. But basically you just have to overwrite the file that is already installed. On windows you can find it in C:Users/youruser/AppData/Roaming/Sublime Text 2/Packages/C#. just look around in your install until you find a folder that is something like that.

  4. Btiger says:

    Thank you for the C#.tmLanguage file, is this support Unity 3.5?

    • Jacob says:

      I’m still using Unity 3.4 but I think this file should work fine with 3.5 at least mostly. I’m not sure if any new keywords were added, but yeah this will work and in the worst case maybe a couple of new keywords will not get highlighted.

  5. Seb Fehr says:

    Thanks for this, really. Sublime is well . . . sublime and I work with unity full time so this a big deal for me.

    Are you aware of any solution to get unity to navigate to the correct line from the Debug Log?

    • Jacob says:

      Not at the moment. I just navigate to the outputted line manually. You could look through the sublime docs and see if there is commandline option to open a file at a specific line and add that command to the settings of Unity, but I’m not sure such a thing exists. You could also look into how it was achieved with notepad++ and see if you can adapt it to sublime. Automatically navigating to the line is something I would find more annoying then usefully so I’m not really interested in getting it working. But if you happen to find a way feel free to comment back here and I’ll add a reference in my post.

      • Jacob says:

        I take that all back. I just got it to work and it is quite helpful. Post with all the details, as well as a new Sublime text plugin that lets you right click words and search the Unity script reference coming after I get some sleep.

        [WORDPRESS HASHCASH] The poster sent us ’0 which is not a hashcash value.

  6. Thank you for the release!

  7. [...] In my last post about using Sublime Text 2 with Unity3D I covered how to get syntax highlighting working for C# and JavaScript. If that is what your are looking for you can find it here: Using Sublime Text 2 with Unity3D [...]

  8. EdgarAllen says:

    Ooo thanks. I’m not a big fan of monodevelop. Being able to use sublime pleases me so much.

    One question though, is there a way to have the unity c# projects open in the side bar like in monodevelop?

    Or is there is a better workflow for opening other scripts than alt-tabbing back to unity and double clicking the file or using cltr+o and navigating manually?

    • Jacob says:

      Um you might want to hold off on using the file listed here. I have been working on creating more official sublime text packages for supporting unity and getting them included in sublime’s package control.

      I just requested the changes be made on the package control channel this morning and they have not been accepted yet which is why I have not updated this or the other of my posts. You can wait for them to be included in package control or get them early on my git hub page here:
      https://github.com/UnicornForest

      or you could use these older files.

      as for your question about projects files showing up in the side bar… I don’t currently have a better work-flow then what you describe but I’ll look into how sublimes projects work and see if I can write a plugin for that as well but no promises.

      • Jacob says:

        Actually if you have all your scripts under 1 folder (it can have subfolders with more scripts) you can just drag that folder from explorer into anywhere in Sublime and it will create a ad-hoc project showing all the scripts and folders in the side bar.

        Its really easy!

        • EdgarAllen says:

          Thanks for the update files. That’d be great if they are added into package control soon.

          Doh! I should have thought of that. I use that same work-flow for other things. Dragging my scripts folder over will do just fine. Thanks again.

          Cheers,

  9. Tom says:

    This is good stuff. One question though, is there some way to get smart autocomplete? That is have autocomplete find entries outside of the current file? So if I type ‘Vector3.’ I get a list of the properties/methods available on Vector3?

  10. Ben says:

    Thanks for doing this Jacob. Quick question: when this is set up properly, will Sublime Text autocomplete syntax (intellisense style) like Monodevelop does? For instance, if I type a class name that I’ve made, like GameManager. is it possible to get Sublime Text to show me the available methods like it does with built in Unity classes?

  11. very good post, i certainly love this web site, carry on it

  12. Thanks for all info here. I’d also like to know if it is possible to have autocomplete like Tom said 2 posts above.
    Thanks a lot for this.

Leave A Reply