Hey! This thing is still a Work in Progress. Files, instructions, and other stuff might change!

OpenSCAD/Notepad++ Language File (including useage guide)

1582
Downloads
6522
Views
Published on January 3, 2012

Description

This guide is for Windows Users.

I am growing to love OpenSCAD as a creative tool for 3D design but I do find that it's text editor lacks many of the basic features that I appreciate when writing code... Namely:

Auto-Completion
Syntax Highlighting
Collapsible Outline levels
Line Numbering
Automatic Tabbing
Search and Replace
Block Tabbing using the tab key.

I was pleased to discover however that you don't need to put up with the standard text editor. There is a feature that allows you to conveniently use the text editor of your choice with OpenSCAD. My editor of choice is Notepad++ a fast well featured open source text editor. You can download it from notepad-plus-plus.org/

Notepad++ supports many different programming languages but not unfortunately OpenSCAD. It does however have the facility that allows you to create your own language file which I have included here.

This is definitely a work in progress as I have had to make a few compromises due to the limitations of Notepad++'s language editor. I dare say other more experienced coders opinions will differ as to how best to syntax code the OpenSCAD language.

I am currently working on adding auto-complete functionality to notepad++ as we speak. I have included a working though not complete file called openscad_removethisbitandcopy.xml. Currently most if not all functions will auto-complete, what is going to take me longer is adding call-tips to all the functions which would be nice though is not critical.

**** Edits *****
13/5/2012 Added extension type to openscad.xml so that Notepad++ will now automatically detect language when .scad files are opened. Thankyou CrazyJaw, saved me some time there.

Instructions

Installing The Language File

I assume that you have already downloaded and installed both OpenSCAD and Notepad++

1. Download the openscad.xml file.

2. Open Notepad++

3. In the view menu pick the User-Defined Dialogue... item

4. In a moment the User-Defined dialogue box will appear. Select Import

5. The Open dialogue box will appear, navigate to where you downloaded the openscad.xml file and open it.

6. That should be the openscad language file installed. You cna check by looking under the Language menu in Notepad++. At the bottom should be Openscad.

Using Notepad++ With OpenSCAD

1. Open OpenSCAD, Create a new file and save it.

2. In the Design menu select Automatic Reload and Compile

3. In the View menu select Hide editor

4. Leaving OpenSCAD running, now find your newly created .scad file in Windows Explorer, right hand click on it and select Edit with Notepad++

5. Arrange both OpenSCAD and Notepad++ on your screen/s so that both can be seen at once. If you are using Windows Vista or 7 you can drag the title bars of the applications to the left and right sides of the screens to do this easily.

6. Edit your .scad file in Notepad++. Each time you save the file (CTRL+S) you will see that OpenSCAD will recompile the object. You will need to choose the Openscad language from the Languages menu. You will also need to either modify the color scheme for the language file or chose a dark theme for notepad itself.

Enjoy all the advanced text editing features of Notepad++ as well as syntax highlighting of your code!!!

Enabling Auto-Completion in Notepad++

1. Download the file named openscad_removethisbitandcopy.xml and copy it into either c:Program FilesNotepad++pluginsAPIs (Windows 32bit) or C:Program Files (x86)Notepad++pluginsAPIs (Windows 64bit) or something like that depending on your setup.

2. Rename the .xml file to openscad.xml

3. Restart notepad and try it out. Auto-Complete can be activated by clicking CTRL-Space at any time.

4. If you want Auto-Complete to be even more automatic, you can turn it on so that it will detect the functions as you type them... Go to Settings and click Preferences.

5. When the dialogue box appears, select the Backup/Auto-Completions tab. Under the Auto-Completion section choose your preferred options.
Report as inappropriate

You must be logged in to post a comment.

This somewhat worked for me, but 'Save' is grayed out on Notepad++ now. Any ideas?

This is great. Has anyone done the same thing for any Mac code editor?

Actually the connection between Notepad++ and Openscad can be even more automatic than you describe. You need to add a "Run" shortcut to Notepad++ which automatically invokes Openscad. To do that requires:

1.Run->Run... add "C:\Program Files(x86)\OpenSCAD\openscad.exe" "$(FULL_CURRENT_PATH)"

(or whatever your path is) to the dialog box.

2. Save...

3. Name: openscad (actually anything you want to call it)

Assign a key short cut ( I use ALT-O) OK

Exit Notepad++; restart it and you should find openscad under the run menu.

You can now create a file and have Notepad++ automatically start Openscad using that file. If you have set Design-> "Automatic Reload and compile" and View->"Hide Editor" in Openscad you will regenerate the model every time you do a Save (Cntrl-S) in Notepad++

I see what you are doing there. But for some reason I am unable to follow your instructions. Everything seems ok, but when I click the menu item or shortcut nothing happens.

You rock, I hated the amount of TABing I had to do with the built in text editor. This is perfect!

This seems like a great thing and a huge time-saver! Only problem is, I can't seem to install it? I'm running Notepad++ 5.5.1 on a 64 bit Windows notebook. When I open the User Defined Dialog, I don't see any way to do an "Import". I tried to do an Import style themes from the Settings menu, but it didn't do anything.

Any suggestions? What have I done wrong?

Thanks.

I just downloaded Notepad++ v6.2.2 and apparently they moved where to do the import.   I found it under  Language>Define Your Language...>Import  to get it to show up, you must import it, then pick it from the drop down list at the top of the user defined window where it says user define language.  then click on Save As and type in OpenScad.. now there will be an OpenScad entry at the bottom of the language pulldown.   

By the way, I really like having my editor in a separate window, makes it so much nicer on dual monitors!!

Someone give this guy a medal.

Great work by the way, huge time saver.

To get notepad++ to open scad files with the right highlighting, all you have to do is add set the ext="scad" in the second line of the openscad.xml
&
lt;userlang name="openscad" ext="scad"
&
gt;

That will do it automatically for anyone who imports the xml new. If you've already imported it and dont want to do it agian, you can just go to View-
&
gt;User Defined Dialog... And in the pop up, select "openscad" from the "user language" dropdown, and set the "Ext:" input box to "scad"

Thanks for that CrazyJaw. I have updated the xml file with your suggested information. It's only a little change, but it does make the whole experiance so much slicker :)

I installed it but the new language did not appear. I quit notepad++ and started it again but now it crashes and will not start. :'(

I can't find any files modified today apart from the crash dump and I can't find anything in the registry. How do I get rid of it?

Happened to me as well. I just re-installed npp on top of the old install, and it works nicely. You might want to put the xml files in the npp directory as well if you didn't do that.

Thanks for the nice guide and language definition, Justblair. And the autoComplete is sweet as well.

Sorry to hear that Nophead. Which bit did you install? Both files or just the first...

The file that gets altered when you import the language file (first stage) is held in

C:\Users\
&
lt;your user name
&
gt;\AppData\Roaming\Notepad++\userDefineLang.xml

If you have a look at it you will see all the data there in xml format

Awesome, thanks. The syntax highlighting and auto-completion are a huge improvement on the default editor.

Glad you like it. I don't think I could go back now, even after just a few days using the Notepad++ features I consider it indispensable.

Excellent. and great timing. I was just getting fed up with the OpenSCAD editor.

Thanks!

Glad you find it useful Ben. Any feedback about how well or badly the language files are for you will be welcome.

I have not had a chance to play too much with the auto-complete tonight, but I think that it speeds up my coding.

The other thing to remember using notepad++ is the CTRL+Enter keyboard combo which gives you a list of words you have used recently. Very handy for autofilling in variable names.

Everyone thinks openscad is missing block commenting/tabbing but it's not true:

Block comment: Ctrl+d (add shift to un-comment)

Block tab: Ctrl+u (add shift to un-tab)

These shortcuts can be found in the menu.

Thanks Polymaker.. I had been trying to use the tab key... I will amend the instructions accordingly