Search code examples
sublimetext3haxehaxeflixel

Auto class importing in Sublime Text


I'm looking to get auto class importing In Sublime Text. I'm using HaxeFlixel and when ever I add a private var _btnPlay:FlxButton the needed import doesn't automatically show up. How can I get this to be the default action? Is there maybe a hot key I don't know about?

I know in FlashDevelop it can be done as the tutorial I'm following said that was the case:

We need to define a new FlxButton variable to use as our 'play' button. So, type:

private var _btnPlay:FlxButton; Note: if you're using FlashDevelop, it should automatically create an import for FlxButton (import flixel.ui.FlxButton;) at the top of the class. This should be mostly automatic whenever you use class, but if it doesn't add it for some reason, you can enter it manually, or, highlight FlxButton in the editor and hit Ctrl+Shift+1 to add it.


Solution

  • It looks like "Organize Imports" adds missing imports - here's the pull request where this feature was added.

    The default shortcut for it requires pressing Ctrl+Shift+H and Ctrl+Shift+O. You might want to reassign it to something shorter, maybe just Ctrl+Shift+O:

    [
        { "keys": ["ctrl+shift+o"], "command": "haxe_organize_imports" }
    ]