Save time: use macros in your coding

On another topic, @Niki_Christopherson asked what I meant by:

and I’ve personally found Notepad++ macros such an invaluable time-saver that I thought I’d give the answer its own topic. Please note that I’m writing this as an amateur tinkerer, for the sake of my fellow amateur tinkerers – I’m sure that people familiar with actual best practice in coding can usefully correct/expand on what I say here. :slight_smile:

So: If you’re using Notepad++ for your coding, you can go to the “Macro” menu and click “Start Recording.” Then (in whatever .txt file you have open) type some bit of code you use often, like


for example, if that’s the pronoun you’re using for a gender-variable MC or NPC. Click “Stop Recording” when you’ve typed that bit of code, and then “Save Current Recorded Macro.” That will give you a chance to choose a key combo for the macro, like ALT and T. From that point on, instead of typing out ${they} you can just hit ALT T.

This can offer a big improvement in typing speed, especially for those of us who don’t regularly type curly brackets or pipes for a living. It makes it quicker to type out related snippets like ${them}, ${their}, and ${theirs} too. At least, I find it quicker to hit ALT T, delete the “y” and type “m,” than to type out ${them} from scratch.

Sidebar: My own ALT T macro is actually set to:

${they} verb${s}

which helps me make sure any verb coming off of a singular-they will conjugate correctly–I hit ALT T, then highlight “verb” and replace it with the actual word I want, e.g. “run.” So for my enby character Jev, who can have “o” or “they” as their pronouns (and has the variable s set to “s” or “” respectively), ${they} run${s} will show either “o runs” or “they run”. If I just want ${they}, ${them}, etc. it only takes two clicks to delete the verb${s} after I hit ALT T.

For multireplace, you could record a macro of

@{ |}


@{var a|b}

if you want to have placeholder text that’s easy to double-click and replace with your actual variable and flavor text options. In this case, my own macro is actually set to a specific, very common multireplace from my WIP: I hit ALT G and get @{gam ${gamgee}|Yed}, and just replace the terms as needed.

Other examples: I’ve got macros that spit out ${fname} and ${lname} (the MC’s first and last names), which come up a lot. But instead of going on to create macros for all the less common “name” permutation variables – like ${sfname}, the way the character S addresses you (maybe by your first name, maybe by a combo of name and title, maybe just by your title, depending on the level of trust in your relationship), or ${sojname}, the alias the MC is known by in the city of Sojourn – I can just use the ALT F macro for ${fname} and add or replace a letter or two. The core typing speed benefit (not having to hunt-and-peck for $ and { }) is baked into the macro.

Of course macros can also save typing time if you’ve got medium-to-long variable names. For example, because the terminology for magic can vary in my gameworld, I’ve got three related variables: ${wisard}, ${wisardry}, and ${wisardric}. Life’s too short to be typing them out all the time, so ALT W gives me the most commonly used one, ${wisardry}, which I can then quickly edit to either of the other two if needed.

Anyway. Recordable macros are the main reason that I still type the first draft of the game in Notepad++, even though I review, test, and edit my work in CSIDE. I suspect they might fall into the category of something that most non-coders are unfamiliar with, while most coders take them so much for granted that they don’t talk about them. :slight_smile: Hopefully this thread will connect with a few more non-coders who will find them as useful as I have.


Great write-up! Thanks for sharing. I’m curious if you’ve tried autocomplete (for e.g. in the ChoiceScript VS Code extension) for commands and variables and whether that would fill the same usecase here?


I haven’t! :slight_smile: Never used VS Code. A quick glance over at Sargent’s snippet example (which seems to fill a similar role in aligning pronouns with plurals) gives me the sense that that particular solution would demand a meaningful upgrade in my coding skills – but vanilla autocomplete might be enough for the other use cases?

This singlehandedly changed my worldview… :green_heart:

(I have had a doc on the side with my most common weird codes so i can cut and paste, but this is handier)


Autocomplete annoys me, but I loved using macros with conTEXT back in the day. I’ve been using Sublime Text for a long time for the ChoiceScript highlighters but it doesn’t (I think) have a decent macro recording feature - maybe this is what will finally nudge me to VS Code as it looks like you can have highlighters and macros there…

1 Like

Well, that’s my day made. :slight_smile:

I think one reason I’ve found it so helpful is that my pre-COG writing experience (both day job and creative) has been with word processing programs where I learned to use macros for all kinds of shortcuts. Hitting ALT-something or CTRL-something is at this point a natural part of my typing skillset and barely slows me down. Having to hunt for obscure (to non-coders!) punctuation like { or | is like downshifting five gears – and honestly, even $ and @ drop me down a gear or two (you can tell I’m neither an accountant nor a regular social media user).

Reflecting on that, I suspect I’ll continue to find macros a more natural fit than autocomplete… and I suspect that this might say almost as much about my generation as my vocation. :slight_smile: @ might come a lot more naturally if I’d been born even 3-5 years later.


VS Code doesn’t have macros built-in, but you can get the same functionality with extensions.

VS Code does have a robust snippet framework, it’s the best Ive seen out there and I always use in my programming day job.

When I started programming, I used to think auto-complete was annoying. Now it’s an indispensable part of coding, especially if you use Copilot or Tabnine, the suggestions are most of the time spot-on.


I use VSCode almost exclusively, simply because A) it lets me pick the pretty coloration (which is nice and helps my ADHD brain want to focus), B) I used it originally to try to learn how to code in Unity and in Renpy, and C) CSIDE felt unfinished and… I dunno, icky somehow to me? I don’t know, it just didn’t feel like it was working properly and I can’t explain it for the life of me. Might be an autism thing. Anyway.

That said, I use the Choicescript thingie in VSCode, and I’d heard of Macros, but they seemed quite a bit… complicated and code-heavy to me, so I hadn’t thought too much about it, much less pushed myself to use it. But this is actually pretty ingenious, and might same me some time! I’ll see how I can implement it!

Thanks a bunch for elaborating!


Just throwing this out there…

You can also set up a longer macro that will take care of a whole list of variables.

If you go to wherever your user’s notepad++ data is saved (on Windows, just run %appdata%, and go to the notepad++ directory), you can directly edit shortcuts.xml (I suggest backing it up first to .bk before you do this).

You can see the format in the file itself, using the built-in macros as a guide. A quick how-to:

  1. Never open the xml file in notepad++!! Use notepad to edit it.

  2. Every macro begins with a macro name. Example:

  3. The second line of every macro is the same–including the numbering of 1700:

  4. The third line is where you begin your actual text changes, and for each change, you must use a set section of entries. Example below:

  1. In the above example, I’m using the macro to replace $!{name} with Zararya. You can do the exact opposite. So, if you prefer not to code and write at the same time for sections, you can use a set name for the MC (or just use MC), and reverse the above, so the macro will replace MC with $!{name}
  2. You don’t have to stop there, either. For this single macro, you can replace as many text entries as you like. Below is more of this macro (but not the entirety):

You can do this with as many variables at you want, tie them to a keystroke (you can do that in the line where you set the macro name, and run it on entire chapters at a time without having to set multiple keystrokes for single replacements.

An example of how to do this with coding different gendered pronouns in the game:


I’m curious now. Why is that?

Because, when you open notepad++, it is accessing your user settings, of which the macros are one. So that xml file is in use. If you use notepad++ to edit it, it will appear to be okay until you run the macro, at which point it will bomb.

And it will corrupt the xml file as well, so you have to go back to your backed up file.

You could copy the file elsewhere and edit it there though, and then copy the edited one in the original location?

Yep, you could do it that way. I’m too lazy to do that. :stuck_out_tongue:

Notepad++ has had this capability sitting right there and I’ve been typing everything out by hand like a sucker this whole time? I am going to destroy something beautiful.

1 Like

Sorry, this is probably a silly question… but what’s the advantage of doing it this way over using the built-in find-replace function? I know CTRL H from a whole lot of other programs; I don’t speak “params” well enough to have any idea what’s going on in the example code. :slight_smile:

It’s not a silly question. For me, it’s mainly a personal preference. The find/replace function works fine, but it’s time consuming for me, and I can’t write and code at the same time (I’ve been playing around with a possible game and learned this the hard way). So it’s easier for me to write chunks in Word or Notepad++ and just use special “words” where certain code would go, then run the macro in Notepad++ on what I’ve written.

Whether or not you go for a keyboard shortcut, the named macro you set up is in a dropdown box in Notepad++, so all you have to do is click “Macro” and the name of the macro you set up and it instantly replaces everything. It actually works well for multireplace as well, both the way you said and this one. It’s a bit more work up front than the way you posed, but it does the find/replace in a huge chunk with the click of a button.

Oh, and you don’t have to speak ‘params’ to get this. This is what’s going on behind the scenes when you record your macro. It’s just a lot longer macro. :slight_smile:

1 Like

Yes, but Notepad++ has kindly dressed it up in a natural language user interface for me. I literally have no idea what any of the numbers in your example are doing or what any of the labels mean.

Message = 1700 in the second line of every macro? What message is being sent by that? Is it someone’s birthday, or favorite steakhouse, or favorite statistical regulation? What message am I sending by changing it to 16-something in my edited code? A rejection of modernity for a chance to steer the Westphalian era in some radically different direction? (Is that an edit I’m making at all, or does the program itself automatically pick “message” numbers that it deems appropriate for surnames or pronoun variables?)

What’s a wParam, sParam, and lParam? West, south, and left? Why are they mostly but not always 0?

I appreciate your taking the time to lift up the hood, but it might as well be in binary for all that I can understand what’s going on there, let alone use it to accomplish anything. :slight_smile:

1 Like

Simple answer: each macro requires those sections because it’s part of the syntax.

Longer explanation is here: Searching | Notepad++ User Manual

If you scroll down a bit, it will explain what each line does.

The main gist, however, is that you don’t really need to worry about them. Every single macro you set up has the same structure, starting with the macro name line, then going to the line with 1700 all the way through 1701, beginning again for the next piece of text you want to change.

So the only thing you really need to remember to do it this way is to copy that chunk for each thing you want to change and then add the text you want to replace on the 1601 line (in quotes) and put the text you want to replace it with on the 1602 line. Every other line in that block stays the same and you need not edit it.

And the same holds true for each piece of text you want to change using that same macro, so you just repeat the process until you include everything you want to find/replace on. That’s why I showed a longer example, with a few bits of text changed, to show that the only lines that need to be changed are the one with 1601 (your “find”) and then the line with 1602 (your '“replace”).

I hope that makes more sense to you. If not, if you want to give me a bunch of variables you want to do this with, I could do it quick (tomorrow, I’m about to crash tonight) so you can drop it in your xml and see it in action. Unless what you want needs a ton of regular expressions, in which case I’ll run away screaming. :stuck_out_tongue: I loathe regex…

1 Like

Thanks for trying to explain it, and even more for the offer to help implement it. As I said above, it’s a foreign language (i.e. “syntax”) I don’t currently understand at all, and that I’d need to learn before I actually understood what I was doing by changing 1700 to 1601 or 1625 or what have you. While I don’t doubt I could learn it, especially with a guide as patient as yourself, the thing I’ve always appreciated about Choicescript is that it relieves me of the need to try. :slight_smile:

I’m happy to stick with the Find-Replace function for changing text. And I’ve enjoyed the recordable Macros function because it’s handy without requiring me to dive into the user manual to understand how the code of Notepad++ itself works.

Maybe one of these years I’ll see if I can get my head around the *param or array functions of Choicescript. That’ll be a big bridge to cross, and one I’ve not thrown myself at so far because I’ve not seen where it would help with what I’m trying to do in my game. For now, I’ll keep working with what I do understand – and do it a little faster, thanks to Notepad++'s Macros.


Not the right place to discuss this, but if you wouldn’t mind PMing me some feedback, or dropping it in the CSIDE thread, I’d be very appreciative. Even if it is just a bunch of random incoherent thoughts. See, I get a lot of feedback saying CSIDE is great or xyz feature is helpful, but precious little from those who decide it isn’t up to snuff (and I know there’s more than a few of those people!).