Create Your Own Code for Code

By Jennifer Neighbors, Senior Consultant

Today while writing the same line of code for what seemed like the hundredth time in the same day, I realized I needed to find a better way. Do you have a line of code you use over and over? For me, it’s the first line in my typical code block – one that’s intended to get and store the id number of the current record. Most of my code starts with this line and it’s the same line no matter what the database or table I am working in:

let xCurrRec := number(Id);

I need this short line of code, but I’m tired of typing it over and over again. In my moment of frustration, I had a realization. My iPhone has a text replacement feature that allows me to store shortcuts for frequently used names and phrases. My Mac will do the same

How? From the Apple menu, select System Preferences and then Keyboard. Under the Text tab press the plus icon. Enter a short “code word” in the “Replace” column. Then, in the “With” column, type the phrase you want it to replace. Press enter. That’s it! Now whenever you type your code word your Mac will insert the phrase you want to use. And this works fine in your Ninox code editor.

As you can see from this illustration, I selected the code word “cr” for my line of code. Next, I experimented to see if I could store a few lines of code rather than just one line and found the problem with this is it’s impossible to enter a carriage return in the available space. The solution is to copy and paste your lines into the “With” column rather than typing them there. I created a code word “sw” to represent a case switch statement. Using my Notes app, I typed this:

switch do





Then I copied and pasted these lines into the “With” column and it worked. I could only see the first line, but all the lines were there. This won’t prevent me having to add my own customization each time I use it, but it will still save time.

When you use this text shortcut method, you will see your substitution appears as a choice. It may seem as though you must use your mouse to indicate that you do indeed want to enter your “With” phrase, an action that would slow you down. Don’t reach for your mouse. Instead, press the spacebar after you type your code word and your text substitution will be instantly made.

 The possible applications for this are endless, aren’t they? If you are like me, tired of typing the same code phrases over and over, and you use Ninox on a Mac, you’re probably already planning what you can do using this simple trick.

Jennifer welcomes feedback and can be reached by email to