sonaht
New Member
Hi Everyone,
Like many of you I have been using Nils KSE editor for scripting however it does not work as good on OS X as it does on the PC (different line endings, problem with big scripts, slightly outdated etc.). This is partly because it is/was ported into OS X not by Nils himself but by someone else.
Please note that this post is not meant in any way to start a war in code editors, just my personal choice and my sharing it with the community. Also I am not affiliated with macromates (the developer of textmate). I merely made a custom bundle to support custom syntax highlighting and folding for KSP for my own(and now your) use.
The cool thing about Texmate is that it does code snippets.
I have spent the last couple of weeks copying every command from the KSP 5.0 Reference Manual and (with a few exceptions) you type only the first 3 letters of a Built-in variable and press "tab" and you are presented with all the commands that
start with those letters. Same goes for all the callbacks, functions, conditional statements etc, they are all typed in and when let's say you want to do an if statement you type "if" press tab and you get a completed if statement where you can tab between all
the various conditions, variables etc... I made it so all the commands come pre typed with the syntax as a placeholder
So if let's say you type "set" and press tab and then type "1" you will get: set_control_par($ui-ID,$CONTROL-PARameter,$value) and you can tab between the various parameters and fill in the different variables.
One thing to note is to select the KSP customization use the shortcut: shift-control-option-command-K or select it in the lower left corner (just like BBEdit)
Here is where you can download the editor (it has a 30 day trial and it's 40 dollars after that I think:
https://macromates.com/
After installation of the software, unzip the attachment of this thread, https://pinartoprak.com/KSP/KSP_OSX.zip (KSP OSX Custom Bundle) double click on ALL the files to install them, the "KSP.tmbundle" file, the "Source.tmbundle" file, the "KSP - *BRIGHT*.tmTheme" file as well as the Inconsolata.otf font file(it's a programmers font that looks really nice).
You can also access all the custom made shortcuts from textmate with the shortcut "control-option-command-K". I also made an excel sheet that documents all the commands as well as their shortcut.
• Escape "~" rotates all typed parameters in the script(aotocomplete). So if you have used "$count" before all you have to type is "$co" and press escape and it will show up ( or it will rotate between $count_1 and $count_2 if you had used these before).
• Command - 4 prefixes variables with the $ sign. I tend to write a variable and decide afterwards if it's a variable or an array or a string array etc so I made a macro with that shortcut that basically goes to the beginning of the word appends $ and goes back to the end of the word. That comes in handy with the above example of autocompletion where you could type "co" without the $ sign, esc to autocomplete and then press command 4 and voila!
• Command-5 prefixes a word with the % symbol (same as above)
• Command-2 is for @ string variables
• Command-1 is for string arrays
• All callbacks are foldable as well as functions, if and while statements.
For custom folding beyond the callbacks you can do it with:
{<custom-fold>}
...
code
...
{</custom-fold>}
• You can comment out a variable or anything by selecting it and pressing "command-forward slash (/)"
• You can also comment a block of code out by selecting it and pressing "option-command-forward slash (/)"
• The assign symbol := can be typed just with the " : " It drives me mad to have to type both all the time so I made a macro that types := when I only type :
• Typing "todo" and pressing tab creates a commend with all the "To do" items that you might need on your script. What makes this feature great is that you can put this anywhere in the script and then pressing "Control - Shift T" gets you a pop up window with whatever notes you made to yourself.
• Typing "head" and pressing tab in the beginning of the document creates a comment header where you can type in all the usually header info.
• The custom coloring that I created is accessed through the preferences (command ,) and you don't have to use it or can customize it to your liking. I made it so there is different colors for variables, arrays, built in or constant variables in capitals, strings, numbers, keywords(if, while, on init, end on etc) and comments. There are also some dark themes that are easier in the eyes for scripting at night.
It can be customized even more with more snippets or macros but I'll add more stuff as I go. You can add more stuff too if you end up using it.
I hope you like it
Best,
Thanos
Like many of you I have been using Nils KSE editor for scripting however it does not work as good on OS X as it does on the PC (different line endings, problem with big scripts, slightly outdated etc.). This is partly because it is/was ported into OS X not by Nils himself but by someone else.
Please note that this post is not meant in any way to start a war in code editors, just my personal choice and my sharing it with the community. Also I am not affiliated with macromates (the developer of textmate). I merely made a custom bundle to support custom syntax highlighting and folding for KSP for my own(and now your) use.
The cool thing about Texmate is that it does code snippets.
I have spent the last couple of weeks copying every command from the KSP 5.0 Reference Manual and (with a few exceptions) you type only the first 3 letters of a Built-in variable and press "tab" and you are presented with all the commands that
start with those letters. Same goes for all the callbacks, functions, conditional statements etc, they are all typed in and when let's say you want to do an if statement you type "if" press tab and you get a completed if statement where you can tab between all
the various conditions, variables etc... I made it so all the commands come pre typed with the syntax as a placeholder
So if let's say you type "set" and press tab and then type "1" you will get: set_control_par($ui-ID,$CONTROL-PARameter,$value) and you can tab between the various parameters and fill in the different variables.
One thing to note is to select the KSP customization use the shortcut: shift-control-option-command-K or select it in the lower left corner (just like BBEdit)
Here is where you can download the editor (it has a 30 day trial and it's 40 dollars after that I think:
https://macromates.com/
After installation of the software, unzip the attachment of this thread, https://pinartoprak.com/KSP/KSP_OSX.zip (KSP OSX Custom Bundle) double click on ALL the files to install them, the "KSP.tmbundle" file, the "Source.tmbundle" file, the "KSP - *BRIGHT*.tmTheme" file as well as the Inconsolata.otf font file(it's a programmers font that looks really nice).
You can also access all the custom made shortcuts from textmate with the shortcut "control-option-command-K". I also made an excel sheet that documents all the commands as well as their shortcut.
• Escape "~" rotates all typed parameters in the script(aotocomplete). So if you have used "$count" before all you have to type is "$co" and press escape and it will show up ( or it will rotate between $count_1 and $count_2 if you had used these before).
• Command - 4 prefixes variables with the $ sign. I tend to write a variable and decide afterwards if it's a variable or an array or a string array etc so I made a macro with that shortcut that basically goes to the beginning of the word appends $ and goes back to the end of the word. That comes in handy with the above example of autocompletion where you could type "co" without the $ sign, esc to autocomplete and then press command 4 and voila!
• Command-5 prefixes a word with the % symbol (same as above)
• Command-2 is for @ string variables
• Command-1 is for string arrays
• All callbacks are foldable as well as functions, if and while statements.
For custom folding beyond the callbacks you can do it with:
{<custom-fold>}
...
code
...
{</custom-fold>}
• You can comment out a variable or anything by selecting it and pressing "command-forward slash (/)"
• You can also comment a block of code out by selecting it and pressing "option-command-forward slash (/)"
• The assign symbol := can be typed just with the " : " It drives me mad to have to type both all the time so I made a macro that types := when I only type :
• Typing "todo" and pressing tab creates a commend with all the "To do" items that you might need on your script. What makes this feature great is that you can put this anywhere in the script and then pressing "Control - Shift T" gets you a pop up window with whatever notes you made to yourself.
• Typing "head" and pressing tab in the beginning of the document creates a comment header where you can type in all the usually header info.
• The custom coloring that I created is accessed through the preferences (command ,) and you don't have to use it or can customize it to your liking. I made it so there is different colors for variables, arrays, built in or constant variables in capitals, strings, numbers, keywords(if, while, on init, end on etc) and comments. There are also some dark themes that are easier in the eyes for scripting at night.
It can be customized even more with more snippets or macros but I'll add more stuff as I go. You can add more stuff too if you end up using it.
I hope you like it
Best,
Thanos