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. (Not a Windows user? Check out Gherkin Syntax Highlighting in Atom.)

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, simply navigate to the Language menu option, go to User Defined Language near the bottom, 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++ through the User Defined Language window, and you’re ready to go! If you download my UDL file from GitHub, make sure to download it as a raw XML file.

Below is a screen shot of an example feature file:

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

(Note: These instructions are based on NotePad++ 7.9.1.)


  1. 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.


    1. Thanks, Andy! this is great.
      The syntax highlighting works fine.
      The Data Tables and Examples etc. may need additions but this community work is what makes this tool so awesome!


  2. 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!



    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++.


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



  3. Would love to figure out how to highlight numbers.
    For example:

    Just the numbers would need to be highlighted.

    I’ve tried a number of scenarios but can’t get it to work.


    1. You *could* play around with the Notepad++ UDL to make it highlight numbers, but I question if you *should*. In Gherkin, numbers are treated just like any other plain text for a step. There is nothing special about them. If you want numbers to be used as step arguments, then I recommend the best practice of surrounding arguments with double-quotes. For example: Given I have a basket with “3” cucumbers. The UDL I provided will highlight any arguments surrounded by double-quotes.


  4. I’m a little late to the party, here. But has anyone been able to accomplish code folding on the scenarios? I just can’t seem to figure that one.


  5. Good post (as always, Yesterday I discovered this blog, it is amazing! I’ve been reading all posts of the BDD-101 series!!)

    Just to add, if you’re a Linux user, you can also install Notepadqq, it already has syntax highlighting for Gherkin. Just open a Gherkin file and then go to Languages -> G -> Gherkin.

    Easy as that!

    Or, if you want to use Notepadqq mainly for working with Gherkin files. In Notepadqq go to Settings -> Preferences -> Languages and select Gherkin as your default Language.))


  6. I have able to Import it into V 7.6.6 I had to save the raw XML as suggested above. It tells me that the import is successful but then I can’t figure out how to use the language. It is not highlighted as the example above.


    1. Hi Ryan. Make sure the files end with the “.feature” extension. You might need to restart Notepad++ or explicitly set the language to “Gherkin” under the Language menu.


      1. Andy thanks for your help. I was finally able to get it work, clearly I was doing something wrong. The only question that I have is when you write out the example tables, what do I need to do in order to have it format correctly?


      2. Hi Ryan! The only formatting that happens to the Examples tables is that the word “Examples” gets stylized. You’ll need to manually space the delimiters. My language extension won’t automatically format them. Sorry!


  7. I have tried this, and it fails to import. I have no idea how notepad++ has changed. Is there anyone that has fixed this?


  8. I try to install notepad++ v7.9.5 but getting an error opening file for writing: C:\Program Files\Notepad++\functionList\c.xml


  9. I have downloaded the xml file you referred and it works like charm even with the latest version of Notepad++. Having said that, is there a possibility to get the existing steps automatically when we do ctrl+spacebar. Am I missing something if it is already there?


    1. I’m glad to hear that you like my plugin! Unfortunately, I don’t think the language features of Notepad++ can enable auto-complete for existing steps (unless they have been enhanced significantly).


Leave a Reply

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

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

Facebook photo

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

Connecting to %s