Home AMX User Forum NetLinx Studio

NetLinx Plugin For Sublime Text

This is a plugin for developers looking for a lighter weight alternative to NetLinx Studio, while still providing powerful functionality. On top of the features provided by Sublime Text, this plugin adds syntax highlighting, color schemes, and build support for NetLinx source code files. This is also a great option for programmers who are looking to use one editor for multiple languages.


Documentation & Download
https://sourceforge.net/p/sublime-netlinx/wiki/Home/

Screenshot
https://a.fsdn.com/con/app/proj/sublime-netlinx/screenshots/sublime-netlinx-02.png


ABOUT SUBLIME TEXT

http://www.sublimetext.com/


Command Palette - The Command Palette holds infrequently used functionality, like sorting, changing the syntax and changing the indentation settings. With just a few keystrokes, you can search for what you want, without ever having to navigate through the menus or remember obscure key bindings.

Multiple Selections - Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.

Customize Anything - Key Bindings, Menus, Snippets, Macros, Completions and more - just about everything in Sublime Text is customizable with simple JSON files. This system gives you flexibility as settings can be specified on a per-file type and per-project basis.
«13

Comments

  • travtrav Posts: 188
    Thankyou

    Was pretty impressed with sublime, and you've done a superlative job with the plugin.

    I think the single most awesome feature is the graphical splash down the RHS of where you are within the file. It's great.

    Haven't had a chance to download the latest version yet, but I will give it a try tomorrow at work, and also install the auto complete everywhere plugin, and have a crack installing ruby and see how the compiler wrapper fares.

    I'd just like to say thank you for giving this to us, as a community of developers, and If I ever meet you, a large quantity of beverages of your choice and a nice meal are on me.

    ** EDIT**

    Ok, so I couldn't wait, the run functionality is AWESOME, and autocomplete everywhere with sublime 3 removes my last gripe about using sublime 2 and the previous version. I hate to say that I am so reliant on autocomplete... and the amount of times I press alt-space in netlinx is just rediculous.

    Also.. on a side note, how in HELL did I not discover sublime text before now? seriously... it's the best thing since mcedit ;)

    For what it's worth, in my opinion you should all stop using NS2 right now and leave its.... how can I put this.... quirks behind. I've waited years for an Eclipse Netlinx plugin and haven't got one, so I give up. I'm using this. <3 Alex.
  • vincenvincen Posts: 526
    Wow thanks for the work and the share, it's really great :) and it runs on Mac OSX :p
    Just missing file transfer features in it :D
  • amclainamclain Posts: 41
    vincen wrote: »
    Wow thanks for the work and the share, it's really great :) and it runs on Mac OSX :p
    Just missing file transfer features in it :D

    Yep! Sublime Text runs on Windows, Mac, and Linux.

    File transfer and compiling require the respective programs provided by AMX to be installed on your system, so yeah, there’s a slim chance those will run on Mac OSX. However, I can tell you from experience that it is possible to run them in Linux using Wine and a small amount of tinkering.

    If you enjoy programming on Mac, you could try setting up a Windows virtual machine with a shared folder between the host and guest. That way, with your project(s) in the shared folder, you could write code on OSX and use the file transfer from the Windows VM.
  • the8thstthe8thst Posts: 470
    Thank you Alex.
    I have been using Sublime for a while to write non-AMX code and love it. I even started a crude Netlinx plugin, but yours sounds like it is light years ahead of what I was working on.

    Now I just need a good RouterOS plugin for Sublime and I can leave NS2 and Notepad++ in the past.
  • TonyAngeloTonyAngelo Posts: 315
    Thank you for this!
  • vincenvincen Posts: 526
    amclain wrote: »
    If you enjoy programming on Mac, you could try setting up a Windows virtual machine with a shared folder between the host and guest. That way, with your project(s) in the shared folder, you could write code on OSX and use the file transfer from the Windows VM.
    Well I was thinking to try to run NSX in Wine so I can call the compilator from Sublime :) the only thing missing would be the transfer capability !
  • GregGGregG Posts: 251
    I don't know how closely wine on mac operation compares to wine on linux, but I have used netlinx studio under wine on linux to compile and load code successfully.

    TPD4, however, was not so good. The properties block controls didn't render as a proper UI element, so I couldn't change any buttons.
  • amclainamclain Posts: 41
    vincen wrote: »
    Well I was thinking to try to run NSX in Wine so I can call the compilator from Sublime :) the only thing missing would be the transfer capability !

    I've updated the documentation because this wasn't very clear: AMX provides FileTransfer 2 as a standalone application. If you can get that installed, you should have the capability to transfer files. :)
  • PhreaKPhreaK Posts: 966
    Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you etc.

    Between this, your Duet bootstrap and other tools, you sir, win at awesome.
  • travtrav Posts: 188
    PhreaK wrote: »
    Between this, your Duet bootstrap and other tools, you sir, win at awesome.

    Told you you'd like it!
  • PhreaK wrote: »
    Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you etc.

    Between this, your Duet bootstrap and other tools, you sir, win at awesome.

    I think he likes it :D
  • travtrav Posts: 188
    I kinda like it too!

    Seriously though... how f***ing good is sublime as an editor... I used to use ultraedit.. then notepad++ for a number of years, but this just blows everything I've ever used out of the water.

    It really is sublime.


    mmmm limes...... now where did I leave the rum and mint.....
  • AuserAuser Posts: 506
    I'm not sure I want to see you after a few drinks Trav :P
  • travtrav Posts: 188
    You've seen me after a lot more than a few!
  • champchamp Posts: 261
    I'm enjoying using Sublime as a text edittorbut can't figure out compilation, please help.

    I can successfully compile using the command line using >netlinx-compile -s my_source_code.axs
    I can't figure out how to make it work with the Sublime build command, do I have to manually edit NetLinx.sublime-build?

    Here's some details that may help point out what I have not done...

    I've successfully installed netlinx-compile and netlinx-workspace. When I select build in Sublime nothing happens.
    The bottom left status bar says Building after the line and column numbers and it says NetLinx on the bottom right of the status bar but the output window is empty and no tko files are created.

    The NetLinx package is installed so I can see NetLinx.sublime-build in the package folder and NetLlinx is selected in Build > System.
    I've put C:\Ruby200-x64\bin in the System Path.
    I have NS3 installed so nlrc.exe is installed at C:\Program Files (x86)\Common Files\AMXShare\COM\
    I have the current project folder open when I attempt to compile.

    I tried creating a new sublime project and adding the project folder to the sublime project.
  • travtrav Posts: 188
    Try this champ
    champ wrote: »
    I'm enjoying using Sublime as a text edittorbut can't figure out compilation, please help.

    Not sure if this is the correct way, but I've found I have to maintain an NLS2 workspace file (.apw) with all the correct additions and includes in the base path of my sublime project, than you can just ctrl-b ctrl-shift-b or F7 from within sublime and all should be well with the world.
  • trav wrote: »
    Not sure if this is the correct way, but I've found I have to maintain an NLS2 workspace file (.apw) with all the correct additions and includes in the base path of my sublime project, than you can just ctrl-b ctrl-shift-b or F7 from within sublime and all should be well with the world.

    Trav's pretty much got it. The only thing I should note is that includes can be placed in subdirectories of the project as long as the entry for the include in the workspace file points to the right spot.


    There is a detailed explanation of the Build: Workspace command, which Sublime executes when you build a NetLinx file. The easiest thing to do is set up the workspace with NetLinx Studio at the beginning of the project with pointers to all of the project files... for now. With your workspace configured, the rest of your time can be spent working in Sublime.


    For anyone who likes to play around with things, try opening a NetLinx Studio workspace file in Sublime.
  • champchamp Posts: 261
    No go unfortunately, there must be something wrong with my install.
    I'll try it on a different PC and see what happens.
  • a_riot42a_riot42 Posts: 1,624
    Does anyone know a way to make column mode work more like Netlinx studio? I don't want to give up the ability to select and highlight columns using Alt Shift, and the way Sublime 3 does it doesn't really make sense to me. You have to Alt Ctrl to move the cursor up or down, and then hit Shift and arrow keys to actually select the text. Unless I'm doing this wrong, this is slower and more inconvenient than NS3.
    Paul
  • travtrav Posts: 188
    a_riot42 wrote: »
    Does anyone know a way to make column mode work more like Netlinx studio?

    I don't know about more like Netlinx studio, but I'll do you a better than Netlinx studio, by selecting with the middle mouse button.
  • a_riot42a_riot42 Posts: 1,624
    trav wrote: »
    I don't know about more like Netlinx studio, but I'll do you a better than Netlinx studio, by selecting with the middle mouse button.

    I don't like using the mouse when typing code. I prefer to stick to the keyboard. All that needs to happen is that the shift and arrow keys need to remain active when selecting text, but to use column mode you have to hit the Ctrl Alt combination and for some reason that disables the shift and arrow keys so that you can only move the cursor up or down in that column. Thanks for the suggestion though.
    Paul
  • travtrav Posts: 188
    Fair enough,

    I do see what you mean regarding the column selection with the keyboard, but after a while of using the multiple cursors approach that sublime uses, I found it to be a lot more powerful.

    Have you tried installing the sublime column select package?
    https://github.com/ehuss/Sublime-Column-Select

    That appears to do what you want, well at least the doc page says it does ^_^

    -Trav
  • a_riot42 wrote: »
    All that needs to happen is that the shift and arrow keys need to remain active when selecting text...

    EDIT: Trav beat me to the column select package while I was writing this.

    At this point the Sublime Text Forum would be the better place to ask this question. Sublime is highly customizable and there is probably a way to do what you want. That being said, you can access all of the key bindings through "Preferences -> Key Bindings - Default", and likewise override any of them by making additions to "Key Bindings - User".

    I personally prefer to stay on the keyboard as much as possible and have found that I rarely need to use column selection. Column selection is a graphical solution to a syntactical problem, which means there are better options out there. If you're a keyboard user, my biggest recommendation is to learn the common VIM keys and enable Sublime's Vintage Mode. Learning to use multiple selections is a must, and is incredibly powerful when coupled with regular expressions.
    dvDEVICE_1		= 10001:1:0;
    dvDEVICE_2		= 10002:1:0;
    dvDEVICE_3		= 10003:1:0;
    dvDEVICE_4		= 10004:1:0;
    dvDEVICE_5		= 10005:1:0;
    dvDEVICE_6		= 10006:1:0;
    dvDEVICE_7		= 10007:1:0;
    

    (VIM KEYS ON)

    This code was created in a matter of seconds by pressing "a" (VIM key "append"), enter 7 times, ctrl+a (select all), ctrl+shift L (split cursor on line), typing "dvDEVICE_ " (space at the end there), ctrl+shift P (command palette), "te p 1" (Text Pastry Number 1 to X), "a" (append), tab several times, "= 1000:" (short a zero, cursor at end of colon), "te p 1" (Text Pastry again), "1:0;".

    Deleting a group of lines is as easy as navigating up/down to the line using "j" or "k", shift+V (select line), "j" (cursor down), "d" (delete).

    Renumbering the devices can be done by navigating to the last digit in the "10001" DPS, ctrl+alt+down arrow (multi-cursor), "x" (remove character). "i" to insert the number(s) you type, or Text Pastry to renumber using a different sequence.

    Renaming all of the devices can be done with ctrl+f (find), "device", alt+F3 (multi-select all matches), escape, "c" (change text), type new name.


    More detailed pattern matching or find/replace is where regular expressions help out, which I won't go into. Based on the examples above, it's probably easier to see how these tools can also be applied to event handlers, arrays, and all sorts of other stuff.
  • a_riot42a_riot42 Posts: 1,624
    trav wrote: »
    Fair enough,

    I do see what you mean regarding the column selection with the keyboard, but after a while of using the multiple cursors approach that sublime uses, I found it to be a lot more powerful.

    Have you tried installing the sublime column select package?
    https://github.com/ehuss/Sublime-Column-Select

    That appears to do what you want, well at least the doc page says it does ^_^

    -Trav

    Thanks. I installed it but it didn't do anything other than disable the way the original column select worked. I couldn't select columns at all, so I uninstalled it. Not sure what happened there.
    Paul
  • a_riot42a_riot42 Posts: 1,624
    amclain wrote: »
    EDIT: Trav beat me to the column select package while I was writing this.

    At this point the Sublime Text Forum would be the better place to ask this question. Sublime is highly customizable and there is probably a way to do what you want. That being said, you can access all of the key bindings through "Preferences -> Key Bindings - Default", and likewise override any of them by making additions to "Key Bindings - User".

    I personally prefer to stay on the keyboard as much as possible and have found that I rarely need to use column selection. Column selection is a graphical solution to a syntactical problem, which means there are better options out there. If you're a keyboard user, my biggest recommendation is to learn the common VIM keys and enable Sublime's Vintage Mode. Learning to use multiple selections is a must, and is incredibly powerful when coupled with regular expressions.
    dvDEVICE_1		= 10001:1:0;
    dvDEVICE_2		= 10002:1:0;
    dvDEVICE_3		= 10003:1:0;
    dvDEVICE_4		= 10004:1:0;
    dvDEVICE_5		= 10005:1:0;
    dvDEVICE_6		= 10006:1:0;
    dvDEVICE_7		= 10007:1:0;
    

    (VIM KEYS ON)

    This code was created in a matter of seconds by pressing "a" (VIM key "append"), enter 7 times, ctrl+a (select all), ctrl+shift L (split cursor on line), typing "dvDEVICE_ " (space at the end there), ctrl+shift P (command palette), "te p 1" (Text Pastry Number 1 to X), "a" (append), tab several times, "= 1000:" (short a zero, cursor at end of colon), "te p 1" (Text Pastry again), "1:0;".

    Deleting a group of lines is as easy as navigating up/down to the line using "j" or "k", shift+V (select line), "j" (cursor down), "d" (delete).

    Renumbering the devices can be done by navigating to the last digit in the "10001" DPS, ctrl+alt+down arrow (multi-cursor), "x" (remove character). "i" to insert the number(s) you type, or Text Pastry to renumber using a different sequence.

    Renaming all of the devices can be done with ctrl+f (find), "device", alt+F3 (multi-select all matches), escape, "c" (change text), type new name.


    More detailed pattern matching or find/replace is where regular expressions help out, which I won't go into. Based on the examples above, it's probably easier to see how these tools can also be applied to event handlers, arrays, and all sorts of other stuff.

    The way I would write that in NS3 would be to type
    dvDEVICE_1 = 10001:1:0
    

    Copy and paste that as many times as needed, column select any part of dvDEVICE_# as long as it contains the digit, hit Alt M to sequentially number them, then do the same for the device numbers and port numbers. This would result in
    dvDEVICE_1 = 10001:1:0
    dvDEVICE_2 = 10002:2:0
    dvDEVICE_3 = 10003:3:0
    dvDEVICE_4 = 10004:4:0
    dvDEVICE_5 = 10005:5:0
    dvDEVICE_6 = 10006:6:0
    dvDEVICE_7 = 10007:7:0
    dvDEVICE_8 = 10008:8:0
    dvDEVICE_9 = 10009:9:0
    dvDEVICE_10 = 10010:10:0
    

    and the only keys I needed after typing the first line was Alt Shift M and the cursor keys so my fingers stay on the same keys the whole time. I've gotten very fast at this, and don't want to change at this point and memorize complicated VIM sequences. My Northgate keyboard selects text a lot faster than normal keyboards so I can do this in a couple of seconds without any thought. The problem when using multiple editors is that each requires different shortcuts which gets confusing. I use NS3 to write Netlinx and am trying Sublime for Perl, and so I was hoping to be able to keep that feature along with the other handy Sublime features but the column select is rather odd and has taken some getting used to. The other editor I use occasionally is Intellij, and column mode is similar to NS3 except you have to trigger it with Shift Alt Insert. NS3 actually is the easiest of the bunch not requiring anything but Shift Alt to select columns.
    Paul
  • champ wrote: »
    No go unfortunately, there must be something wrong with my install.
    I'll try it on a different PC and see what happens.

    One thing you can try before reinstalling is checking the Sublime console. Run the build command on one of the source or include files in your workspace, then bring up the console with Ctrl+~. It should show you the command Sublime is executing:
    Running netlinx-compile --smart -s "D:\Projects\_AMX\lib\netlinx-compile\test\unit\workspace\import-test\import-test.axs"
    

    If that works on the command line, Sublime may be having issues executing shell commands on your computer.
  • PhreaKPhreaK Posts: 966
    I'm glad to say that with the help of this I now have a 100% mac based dev machine - no VM required.



    In order to spin this up I'm using wine to wrap nlrc.exe and a slightly modified compile.rb to support this. I haven't touched ruby before however was able to hack together enough to get this up and going. Amclean, if you wanted to add support the compiler path required is:
    '"wine ' + File.expand_path('nlrc.exe', '~/.wine/drive_c/Program\ Files/Common\ Files/AMXShare/COM') + '"'
    

    In order to get nlrc.exe playing nicely with wine it also needs the Microsoft Visual C++ 2010 Redistributable. This is as simple as downloading from the MS website and running with wine so that it places the required dll's in your wine install. It's probably worth noting that the only AMX app I've been able to fault when running with wine is WebUpdate. The rest (file transfer, NLStudio, TPDesign4 etc) all seem to install and function without issue... touch wood. I'll push some entries into the wine app db when I've had a bit more of a chance to run them through their paces.

    If anyone is running a linux dev box the above process *should* be just as successful.
  • PhreaKPhreaK Posts: 966
    I should also note that ruby 2 or later is required - amclain's scripts use the double splat operator which seems to not exist in early versions. If you're running on Mountain Lion you'll only have ruby v1.8.7. Grabbing a later version is super simple with though via rvm.

    For those of you super short on time this will get you up and going.
    \curl -L https://get.rvm.io | bash -s stable --ruby
    
    Then just make sure it's also in your PATH
    echo "source ~/.rvm/scripts/rvm" >> ~/.bash_profile
    
  • truetrue Posts: 307
    I'd love to go with a Linux dev box at work (it's what I use at home) but the industry is Windows-only; I don't only do AMX after all :)

    But this is something I think I'll try, and will document if anything differs from what you have written.
  • champchamp Posts: 261
    I got this going on another PC and forgot about it but a PM prompted me to share my solution with the community.

    I went back to the original PC to figure out why it didn't work and discovered I had tried to use an existing installation of Sublime Text 2. I removed Sublime Text 2, installed Sublime Text 3 and got it working.

    Here are the exact steps I took:

    I couldn't get the install via version control to work using HG so just downloaded a snapshot from http://sourceforge.net/p/sublime-netlinx/code/ci/default/tree/
    - unzipped the folder into C:\Users\<user name>\AppData\Roaming\Sublime Text 3\Packages
    - renamed the folder to sublime-netlinx-code
    - started Sublime Text v3
    - Selected Tools > Build system > NetLinx
    - Pressed control+B and it worked.
Sign In or Register to comment.