Gherkin Syntax Highlighting in Notepad++

Notepad++ is an excellent text editor for Windows. It is free, lightweight, feature-rich, and extendable. It can handle just about any programming language out there. I use it all the time, especially for config files and quick edits that don’t require a bulky IDE. Seriously, if you don’t have it, download it now.

One of the nifty features in Notepad++ is User Defined Language, which allows users to customize the syntax highlighting for any language. This is invaluable if you use an obscure language or even create your own. To access this feature in version 7.2.2, simply navigate to the Language menu option and choose Define your language…. From there, you can create new user language and set stylers for keywords, operators, and other language facets. Stylers can set font color, size, and style. Users can also import and export UDLs as XML files for sharing. Since the highlighting doesn’t rely upon a context-free grammar, it has its limits. For example, keywords may still be highlighted when not actually being used as keywords in the language. Nevertheless, it’s better than nothing.

Since I do a lot of behavior-driven test automation development, I created a UDL for Gherkin. You can download it from the Automation Panda Github repository – the file is named gherkin_npp_udl.xml. Import it into Notepad++, and you’re ready to go!

Below is a screen shot of an example feature file:

npp_gherkin
An example feature file using my Notepad++ UDL for Gherkin

6 thoughts on “Gherkin Syntax Highlighting in Notepad++

  1. Sudarsan Devarajulu

    Time spent with Andy will save us from reading and extracting information from 10 reference books. I will be downloading this plugin and shall post my experience in this post.

    Like

  2. Pingback: BDD 101: Writing Good Gherkin – Automation Panda

  3. Daniel

    I downloaded
    – a fresh copy of Notepad++
    – gherkin_npp_udl.xml

    I tried to import the xml into Notepad++ (Language > Define you language… > Import…)

    Got the error: Failed to import

    Am I doing something wrong?

    Thanks for the post!

    –Daniel

    Like

    1. Those should be the correct steps. I’ll try to troubleshoot in the next day or two. Maybe there’s a file format problem (unix2dos) or a change in the latest version of Notepad++.

      Like

    2. Ulf

      This could happen if you just download the file. Copy it from the ‘raw’ view instead and create a new file to import.

      //Ulf

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s