NetLinx Plugin For Sublime Text
amclain
Posts: 41
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.
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.
0
Comments
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. Alex.
Just missing file transfer features in it
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.
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.
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.
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.
Between this, your Duet bootstrap and other tools, you sir, win at awesome.
Told you you'd like it!
I think he likes it
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.....
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.
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.
I'll try it on a different PC and see what happens.
Paul
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
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
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.
(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.
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
The way I would write that in NS3 would be to type
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
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
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:
If that works on the command line, Sublime may be having issues executing shell commands on your computer.
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:
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.
For those of you super short on time this will get you up and going. Then just make sure it's also in your PATH
But this is something I think I'll try, and will document if anything differs from what you have written.
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.