Insert Nums – my favorite code editor plugin

Andrzej Wojciechowski

Any modern code editor supports plugins to extend its capabilities. Sometimes they are called “packages” or “extensions” etc. There is a plugin which greatly improved my workflow but I think it’s overlooked by many developers – Insert Nums. Since I started using this package, it became my favorite plugin. There are versions for at least two of the most popular code editors: Sublime Text and Visual Studio Code.

The workflow

I’ve discovered this plugin quite some time ago. But since then I’ve seen multiple people, who would make a great use of this, having no idea that such extension exists. Many people (not only developers) sometimes need to have several consecutive numbers in a file. These can be typed manually, but at some point it becomes tedious. Automatic generation of many consecutive numbers is easy in Excel, but opening a spreadsheet just for this purpose seems unnecessary for such a simple task. That’s where Insert Nums comes in.

In my case, I got tired of manually creating multiple VHDL constants in a package file, describing bus registers’ addresses. Each time I wanted to add a new register with address between other registers, I had to update a lot of values. I though about assigning a value by incrementing a previous constant’s value, but that just moves the problem. What if I decide to change the name of a constant, or delete it? It’s too much work to remember and deal with all of this.

A similarly dull task used to be assigning values to each array element – like in the example code in one of my previous posts. I’m sure I am not the only one disliking manually typing several consecutive numbers.

Then I discovered Insert Nums – a package for my editor of choice: Sublime Text. And it quickly became my favorite plugin. Now I can’t even imagine not having this wonderful extension.

How the plugin works

It’s very simple. You just need to create multiple cursor/selection in places where you want to generate numbers. Or letters – if that’s what you need. Then just hit a keyboard shortcut (Ctrl+Alt+N or Cmd+Opt+N) and type in the start number and a step with a colon in between. That’s it!

By default Insert Nums generates number starting at 1 with a step 1. But simply type in 0, to start with 0 (and keep a default step of 1). The same way you can generate float numbers, negative number and even letters.

Another great option I use frequently is the ability to define a format. For example I often use 0:4~04X option to generate the aforementioned registers’ addresses. This results in a list of hexadecimal numbers starting at 0 with a step of 4.

There are many more options to use described in the plugin’s README. Give it a try and I’m sure you won’t regret that.

1 thought on “Insert Nums – my favorite code editor plugin”

Comments are closed.