Configuring Notepad++ for Ren'Py

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
rabcor
Regular
Posts: 81
Joined: Sun Mar 17, 2013 3:07 pm
Projects: None (Need a programmer?)
Organization: Cestarian Games
Contact:

Configuring Notepad++ for Ren'Py

#1 Post 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.
Last edited by rabcor on Fri Feb 19, 2016 2:33 am, edited 3 times in total.

User avatar
Psieye
Newbie
Posts: 6
Joined: Thu Jan 01, 2015 2:21 pm
Contact:

Re: Configuring Notepad++ for Ren'Py

#2 Post 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 36082 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"/>
Attachments
functionList.xml
For 'bookmarking' labels, screens, functions and classes in Ren'py (or Python). Now can cope with parentheses in class names.
(5.14 KiB) Downloaded 2759 times
userDefineLang.xml
Ren'py UserDefinedLanguage settings for Notepad++
(5.69 KiB) Downloaded 2918 times
Last edited by Psieye on Tue Jan 13, 2015 2:36 pm, edited 1 time in total.

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Configuring Notepad++ for Ren'Py

#3 Post 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.)
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Configuring Notepad++ for Ren'Py

#4 Post by trooper6 »

Obscura, did you do live composite for Coming Out on Top?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Configuring Notepad++ for Ren'Py

#5 Post 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.
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
Psieye
Newbie
Posts: 6
Joined: Thu Jan 01, 2015 2:21 pm
Contact:

Re: Configuring Notepad++ for Ren'Py

#6 Post 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.

User avatar
Psieye
Newbie
Posts: 6
Joined: Thu Jan 01, 2015 2:21 pm
Contact:

Re: Configuring Notepad++ for Ren'Py

#7 Post 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.

Shakezula
Regular
Posts: 67
Joined: Wed May 20, 2015 8:01 pm
Contact:

Re: Configuring Notepad++ for Ren'Py

#8 Post 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)

User avatar
rabcor
Regular
Posts: 81
Joined: Sun Mar 17, 2013 3:07 pm
Projects: None (Need a programmer?)
Organization: Cestarian Games
Contact:

Re: Configuring Notepad++ for Ren'Py

#9 Post 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.

Prismatic
Newbie
Posts: 3
Joined: Tue Sep 05, 2017 6:04 am
Contact:

Re: Configuring Notepad++ for Ren'Py

#10 Post 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)

User avatar
docclox
Newbie
Posts: 20
Joined: Thu Oct 12, 2017 6:26 am
Contact:

Re: Configuring Notepad++ for Ren'Py

#11 Post 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).

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Configuring Notepad++ for Ren'Py

#12 Post 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.

User avatar
neometalero
Regular
Posts: 196
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Configuring Notepad++ for Ren'Py

#13 Post by neometalero »

rabcor wrote: Fri Nov 22, 2013 4:09 pm 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.
Tks a lot for posting this. The atom editor was driving me crazy. I love notepad++ and now I can use it for Renpy, im in heaven.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
neometalero
Regular
Posts: 196
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Configuring Notepad++ for Ren'Py

#14 Post by neometalero »

This was really useful, but I have a doubt, the styles seem to not work using this. No matter what style I select the text looks the same (only the background color changes). Any idea how I can fix this?
Image
Psieye wrote: Thu Jan 01, 2015 3:41 pm 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

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"/>
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

seanthiar
Newbie
Posts: 4
Joined: Sun Jun 14, 2020 11:55 am
Skype: seanthiar
Contact:

Re: Configuring Notepad++ for Ren'Py

#15 Post by seanthiar »

Psieye wrote: Tue Jan 13, 2015 2:42 pm 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.
Is there an update for the new structure used by NP++ ? - There is no functionslist.xml and this instructions does not work anymore. There is a now a directory functionlist in the np++-directory. Maybe it would be enough if someone with a working implemention just exports his user defined language and loaded the file up.

Seanthiar

Post Reply

Who is online

Users browsing this forum: No registered users