DEV Community

Cover image for The Developer Tool You Can't Live Without
Jeremy Morgan for Pluralsight

Posted on • Originally published at jeremymorgan.com

The Developer Tool You Can't Live Without

I'm introducing a text/code generation tool that you will fall in love with. If you're a developer or someone who works with text or tabulated data you need this tool.

It's called Nimble Text and it's awesome. Here's how the developer of Nimble Text describes it:

You can be more awesome at your job by keeping this tool always within reach.

NimbleText is a text manipulation and code generation tool available online or as a free download. It magnifies your ability to perform incredible feats of text and data wrangling.

So it's a bold claim to say this will make you better at your job. Sounds crazy right?

I have been using this for years (since 2011-2012) and I can tell it's certainly made me more effective.

Download it and follow along.

How Nimble Text Works

Nimble Text

If you look at the screen that comes up when you first run it, you can get a really good idea of how it works.

You paste in some data, usually in columns and rows (Comma, tab-separated, etc.)
You put in your pattern ($0, $1, etc represents the columns)
For each row of data, it will substitute the values and display the results.

in the sample above, you can see rows of data that appear to be last name, first name, company name.

So let's look at the top row. In our substitution pattern, we're creating an email and it shows $1 (2nd column, starts at 0) which we know is a first name. Then we have a period, and then $0 which we know is the last name, then @ $2 .com which we assume will make Initech.com.

One of the coolest parts of this is that the pattern doesn't need to be line by line and you don't need to be a Regex expert to do this.

Here's another example of how you can quickly add quotes around CSV values. This is using data from Mockaroo.

So we take this CSV file and dump it in the input:

Nimble Text

Then we use this simple pattern, which puts quotes around all the values:

Nimble Text

We press generate, and get this:

Nimble Text

It's that easy! But this is isn't really impressive, because you probably aren't doing a ton of CSV format conversions on a daily basis. But there's a lot of potential here.

How I Use This as a Developer

So there are tons of things you can do with this that are explained on their website. You can do cool things like remove leading trailing and leading spaces or convert spaces to tabs. I love using things like converting to Camel Case and I've done weird stuff with Base64 encoding.

I won't repeat what's already been written there. I'll tell you how I've been using it all these years.

Let's take our sample data set:

Nimble Text

And we'll see what we can do with it.

Create JSON

Let's say I want to make JSON out of this. I would put in a pattern like this:

{
  "id": $0,
  "first_name": "$1",
  "last_name": "$2",
  "email": "$3",
  "gender": "$4",
  "ip_address": "$5"
}
Enter fullscreen mode Exit fullscreen mode

Nimbletext then prints this out:

Nimble Text

and it will repeat for every row of data. Very cool, and easy.

Make some objects

So as a C# Developer sometimes I'd generate fake data and then use it for Unit testing. With our sample data, I would create a class like this:

public class Person
{
    public string Name { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string Gender { get; set; }
    public string IPAddress { get; set; }
}
Enter fullscreen mode Exit fullscreen mode

Then, let's say I want to create a collection of these objects. I then enter a pattern like this into Nimble Text:

new Person { Id = $0, FirstName = "$1", LastName = "$2", Email = "$3", Gender = "$4", IPAddress = "$5" },
Enter fullscreen mode Exit fullscreen mode

Then, I click "calculate" and get this:

Nimble Text

Which generates a nice set of mocked objects for testing:

List<Person> people = new List<Person>
{
    new Person { Id = 1, FirstName = "Derick", LastName = "Giorgietto", Email = "dgiorgietto0@freewebs.com", Gender = "Male", IPAddress = "193.214.16.47" },
    new Person { Id = 2, FirstName = "Jorey", LastName = "Bertomieu", Email = "jbertomieu1@pcworld.com", Gender = "Female", IPAddress = "228.52.120.198" },
    new Person { Id = 3, FirstName = "Jordana", LastName = "Ofield", Email = "jofield2@mashable.com", Gender = "Female", IPAddress = "242.56.206.162" },
    new Person { Id = 4, FirstName = "Zelda", LastName = "Pett", Email = "zpett3@google.nl", Gender = "Female", IPAddress = "53.184.3.220" },
    new Person { Id = 5, FirstName = "Malia", LastName = "McCuffie", Email = "mmccuffie4@noaa.gov", Gender = "Female", IPAddress = "100.137.97.15" },
    new Person { Id = 6, FirstName = "Juliet", LastName = "Sivior", Email = "jsivior5@scientificamerican.com", Gender = "Female", IPAddress = "77.243.6.34" },
    new Person { Id = 7, FirstName = "Trista", LastName = "Filde", Email = "tfilde6@narod.ru", Gender = "Female", IPAddress = "24.158.23.9" },
    new Person { Id = 8, FirstName = "Bartlet", LastName = "Pankhurst.", Email = "bpankhurst7@cmu.edu", Gender = "Male", IPAddress = "61.253.135.113" },
    new Person { Id = 9, FirstName = "Giorgi", LastName = "Verbeke", Email = "gverbeke8@utexas.edu", Gender = "Male", IPAddress = "2.43.176.188" },
    new Person { Id = 10, FirstName = "Issy", LastName = "Ramplee", Email = "iramplee9@com.com", Gender = "Female", IPAddress = "53.253.248.96" }  
};
Enter fullscreen mode Exit fullscreen mode

I have done this countless times over the years. Once you get it into your regular workflow, mocking up data takes seconds.

SQL Statements

You can even make SQL statements like this:

Pattern:

$ONCEINSERT INTO Person (id, first_name, last_name, email, gender, ip_address) VALUES
$EACH($0, "$1", "$2", "$3", "$4", "$5"),
Enter fullscreen mode Exit fullscreen mode

The $ONCE variable prints the first statement, then $EACH loops through after that. So you get this in return:

INSERT INTO Person (id, first_name, last_name, email, gender, ip_address) VALUES 
(1, "Derick", "Giorgietto", "dgiorgietto0@freewebs.com", "Male", "193.214.16.47"),
(2, "Jorey", "Bertomieu", "jbertomieu1@pcworld.com", "Female", "228.52.120.198"),
(3, "Jordana", "Ofield", "jofield2@mashable.com", "Female", "242.56.206.162"),
(4, "Zelda", "Pett", "zpett3@google.nl", "Female", "53.184.3.220"),
(5, "Malia", "McCuffie", "mmccuffie4@noaa.gov", "Female", "100.137.97.15"),
(6, "Juliet", "Sivior", "jsivior5@scientificamerican.com", "Female", "77.243.6.34"),
(7, "Trista", "Filde", "tfilde6@narod.ru", "Female", "24.158.23.9"),
(8, "Bartlet", "Pankhurst.", "bpankhurst7@cmu.edu", "Male", "61.253.135.113"),
(9, "Giorgi", "Verbeke", "gverbeke8@utexas.edu", "Male", "2.43.176.188"),
(10, "Issy", "Ramplee", "iramplee9@com.com", "Female", "53.253.248.96")
Enter fullscreen mode Exit fullscreen mode

Easy as pie! Anything you can do with JavaScript you can do with Nimble Text.

HTML Tables

So this is odd but something I've had to do in the past, and Nimble Text works great for it. Here's how you create an HTML table for our sample data:

$ONCE<table>
$ONCE    <tr><th>ID</th><th>First Name</th><th>Last Name</th><th>Email</th><th>Gender</th><th>IP Address</th></tr>
$EACH    <tr><td>$0</td><td>$1</td><td>$2</td><td>$3</td><td>$4</td><td>$5</td></tr>
$ONCE</table>
Enter fullscreen mode Exit fullscreen mode

Click generate and there it is:

Nimble Text

A usable HTML table!!

Conclusion

This tool will help you become a better, more effective developer. You can use it for all kinds of code generation. I've done some crazy things with the Keywords and Functions in this program. You can write code to generate code.

I've seen the most benefit with time savings. Things like mocking data or processing CSVs are boring and tedious. When you're doing boring tedious things you make mistakes. So once you work this tool into your workflow you'll work faster with fewer mistakes.

Once it becomes a part of your routine you won't want to work without it.

Download it, try it out, and let me know what you think!

If you want to learn how to reduce complexity in data, check out this course. It covers several techniques for optimizing data.

Top comments (8)

Collapse
 
moopet profile image
Ben Sinclair

I think what you've described is mail merge from the 1980s, or possibly snippet managers.

I tend to do this in Vim, because I'm too lazy to learn any of those programs' syntaxes.

Collapse
 
timothymcgrath profile image
Timothy McGrath

This is the best for SQL queries that I need to write off of a set of data. Like when someone sends me a list of names to add to a database. I can just turn it into a bunch of INSERT statements. It's a lifesaver.

Collapse
 
katieadamsdev profile image
Katie Adams

Like this a lot

Collapse
 
sheldonhull profile image
Sheldon

I evaluated that in the past. Pretty cool. Most of my needs have been solved by vscode and some powershell type scripts when needed. This requires a lot less effort to get there so it's a great tool to have for sure.

Collapse
 
theodesp profile image
Theofanis Despoudis

Cool

Collapse
 
jasterix profile image
Jasterix

This is great. I've been using Excel to the same end but this might be better

Collapse
 
baharajr profile image
Bennett(he/him)

I think this is the tool I needed. Thank you

Collapse
 
codemouse92 profile image
Jason C. McDonald

This is not unlike my own Redstring project (which I still have to go finish). Nice work!