Page 1 of 1

Configuring Notepad++ for Ren'Py

Posted: Fri Nov 22, 2013 4:09 pm
by rabcor
I recently started using Ren'Py and noticed how it doesn't even recommend Notepad++ as a default editor, i found this weird since in my opinion Notepad++ is the most convenient free editor i know about, and it's my editor of choice for almost all of my coding.

But when i tried using it with Ren'Py, i found out why it wasn't recommended.

1) It doesn't by default detect .rpy as a "python" file, so it won't have any styling at all to help you with the code syntax.
2) By default, Notepad++ uses Tabs for indentation, so if you're using it you need to tap space 4 times instead of just pressing tab. It will also sometime generate tabs when you paste code into it.

It didn't take me long to figure out that this can easily be fixed, and as soon as i figured it out and didn't see any guide for it here, i decided to write this in case someone else is having this problem.

1) To solve this, go to Settings -> Style Configurator, then find "Python" in the Language menu, and below it you will see a text box for "User ext.". Enter "rpy" (without quotation) into this box and Notepad++ will detect .rpy files as python scripts.
2) Go to Settings -> Preferences -> Tab Settings, find "Tab Size" and make sure it is set to "4" then check the "Replace by space" Checkbox, and Notepad++ will use spaces instead of tab for indentation.

After these steps i find it very comfortable to use Notepad++ for writing/editing my Ren'Py scripts :) Hope this was helpful to someone.

Please read comments, this section/links are outdated

Note: If you want Ren'Py specific syntax highlighting, SusanTheCat made a guide for that. If that info is not enough for you there is a thread on Notepad++ Syntax Highlighting for Ren'Py. If you want Ren'Py specific highlighting you should undo/skip step 1 of this guide.

Re: Configuring Notepad++ for Ren'Py

Posted: Thu Jan 01, 2015 3:41 pm
by Psieye
At the time of writing, I am using Notepad++ v6.6.9

Some of the information in the above links was a little outdated so I wrote an improved version of the settings for Ren'py in Notepad++. These are in the two attachments to this post: userDefineLang.xml and functionList.xml. Both should be placed in %APPDATA%\Notepad++ (assuming Windows, just type "%APPDATA%" into the Windows Explorer address bar). Make backups of the original files as appropriate and then (re)open Notepad++.

userDefineLang.xml

This defines a new option under the "Language" menu bar: "RenPy". I've taken SusanTheCat's original and improved it. As has been noted, Python-style folding via indentation is hard coded and thus isn't available for "RenPy". I've provided an alternate folding mechanism ("fold-by-comments", see below). If you must have fold-by-indent, see these instructions to make Python recognise Ren'py keywords.

This custom defined "RenPy" language makes Notepad++ do the following: (you can change these settings in the UDL GUI. To open, click on "Language >> Define your language..." and set "User Language:" as 'RenPy')
  • Colour code various keywords. I've tried to group the keywords into sensible categories, each with their own colour. If you disagree with my choices, edit them under the "Keyword Lists" tab and fiddling with the "Styler" button.
  • Highlight a standalone '$' when not in a string or comment. This way, if you type "$ myVar=1.0", the '$' will be easily visible making it clear this is a Python line. It won't work if you type "$myVar=1.0", you must give the '$' space before and after. This behaviour can be edited under the "Keyword Lists" tab.
  • Highlight the rest of the line when encountering a "TODO:", "FIXME:", "BUG:" or "TEST:". This highlighting will override any other colour choices. Useful for reminders in comments. This feature can be edited under the "Operators & Delimiters" tab.
  • Enable folding between a "codeBlc" and a "endBlc". This works even when found in comments. See example below. To change the colouring or the spelling of these triggers, look under the "Folder & Default" tab.
  • Highlight a word if it starts with '@'. This works even inside comments. To change, go to the "Keyword Lists" tab.
Here is an example of using fold-by-comments:
FoldByComment.jpg
FoldByComment.jpg (21.84 KiB) Viewed 14913 times
functionList.xml

SusanTheCat talks of Function List at the bottom of this post. To switch it on, click on "View >> Function List". The .xml file is necessary to tell Notepad++ what to look for when populating Function List. I've written it to look for the following pattern:
  • "label", "screen", "function", "class" at the start of a line (optionally after some whitespace)
  • exactly one space (i.e. ' ')
  • some name containing letters, digits, '_', '(' and/or ')'
  • followed immediately (i.e. no spaces) by a ':'
Once setup, you can double click on a name in Function List and Notepad++ will automatically jump to it. By default, this will only work if you've set the Language to be "RenPy" as defined in userDefineLang.xml. If you'd rather set the Language to Python but still want to use Function List, uncomment this line in functionList.xml (near the top, inside the <assocationMap> node):

Code: Select all

<association langID = "22" id="renpy_marks"/>

Re: Configuring Notepad++ for Ren'Py

Posted: Thu Jan 01, 2015 4:20 pm
by Obscura
Once you get comfy with Notepad++ I recommend installing and learning how to use the Fingertext plug-in, which lets you trigger and paste snippets of code on the fly. (It was sooo helpful when coding sprite expressions, which in my script, is basically the same formula but with three or four ever changing variables.

If you have expression changes for nearly every line of dialogue (with frequently changing eyes/mouth/brows etc., the plug-in can save you a lot of pain.)

Re: Configuring Notepad++ for Ren'Py

Posted: Thu Jan 01, 2015 4:24 pm
by trooper6
Obscura, did you do live composite for Coming Out on Top?

Re: Configuring Notepad++ for Ren'Py

Posted: Thu Jan 01, 2015 4:34 pm
by Obscura
Yes I did! LiveComposite with condition switches and interpolation statements (I think that's what they're called?)

Let me know if you have any questions. Warning: I am a terrible coder and anything useful in my game, programming-wise, were from Saguaro and Badriel.

Re: Configuring Notepad++ for Ren'Py

Posted: Thu Jan 01, 2015 4:36 pm
by Psieye
Obscura wrote:Once you get comfy with Notepad++ I recommend installing and learning how to use the Fingertext plug-in, which lets you trigger and paste snippets of code on the fly. (It was sooo helpful when coding sprite expressions, which in my script, is basically the same formula but with three or four ever changing variables.

If you have expression changes for nearly every line of dialogue (with frequently changing eyes/mouth/brows etc., the plug-in can save you a lot of pain.)
That does sound like the sort of thing I'd otherwise have to write an AutoHotkey script for (and I'm not hardcore enough to massage vi into the ultimate coding tool). Thanks for the tip.

Re: Configuring Notepad++ for Ren'Py

Posted: Tue Jan 13, 2015 2:42 pm
by Psieye
A new version of functionList.xml has been uploaded to my previous post. It can now cope with class names like "fooBar(baz)" i.e. it works with Python's class inheritance.

Re: Configuring Notepad++ for Ren'Py

Posted: Wed May 20, 2015 8:28 pm
by Shakezula
Thanks this is great, I always preferred Notepad++ for coding. The poor variety in editor support is pretty disappointing.

Actually, it would be great if there were an unofficial topic that supplies updated user defined languages for other preferred editors. I'm sure this one could use an update. (For example, default is a keyword in 6.99.4)

Re: Configuring Notepad++ for Ren'Py

Posted: Fri Feb 19, 2016 2:31 am
by rabcor
Oh yeah I can imagine it being a bit outdated by now. I haven't exactly been active here; I mostly use sublime now since I hopped over to Linux, but glad to see people are updating this. I will add a note to the OP to read comments.

Re: Configuring Notepad++ for Ren'Py

Posted: Tue Sep 05, 2017 6:28 am
by Prismatic
rabcor wrote:
Fri Nov 22, 2013 4:09 pm
2) By default, Notepad++ uses Tabs for indentation, so if you're using it you need to tap space 4 times instead of just pressing tab. It will also sometime generate tabs when you paste code into it.

2) Go to Settings -> Preferences -> Tab Settings, find "Tab Size" and make sure it is set to "4" then check the "Replace by space" Checkbox, and Notepad++ will use spaces instead of tab for indentation.
Small update, this is how to do it in newest version of Notepad++ in case someone else have trouble finding it, like I had.

Settings -> Preferences -> Language-> Tab settings -v "Replace by space" (Check the box)

Re: Configuring Notepad++ for Ren'Py

Posted: Tue Oct 17, 2017 4:38 am
by docclox
Prismatic wrote:
Tue Sep 05, 2017 6:28 am
Small update, this is how to do it in newest version of Notepad++ in case someone else have trouble finding it, like I had.

Settings -> Preferences -> Language-> Tab settings -v "Replace by space" (Check the box)
Does anyone know if there a way of doing this just for a defined RenPy language? I use my np++ for other programming tasks as well, and for most of them I would prefer to keep tab characters for the indentation.

(Apologies if that's already been addressed. I read the thread, but this point wasn't clear and experiment seems to suggest I'll be changing the setting globally).

Re: Configuring Notepad++ for Ren'Py

Posted: Wed Dec 06, 2017 4:37 am
by ComputerArt.Club
Thanks for this!! I am hoping to teach my after school students to make a game with Renpy but I was having problems getting Editra to run over the network (a temporary measure due to obstacles regarding the installation of software on the computers here). Notepad++ seems to work fine so far and the setup seems to have worked. The portable version is also tiny, which is convenient. We use mostly portable and open source/free apps as it makes it easier for the students to use the software at home.