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:

(Note: These instructions are based on NotePad++ 7.9.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.
LikeLike
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!
LikeLike
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
LikeLike
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++.
LikeLike
This could happen if you just download the file. Copy it from the ‘raw’ view instead and create a new file to import.
//Ulf
LikeLike
Worked for me!
Thank you!
LikeLike
try used online notepad it’s very simple
http://www.guinbox.com/note
online notepad
LikeLike
Great Work, Awesome!!!!
LikeLike
Would love to figure out how to highlight numbers.
For example:
1
20
2018
12345678901234567890
2018-07-05
2018/07/05
Just the numbers would need to be highlighted.
I’ve tried a number of scenarios but can’t get it to work.
LikeLike
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.
LikeLike
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.
LikeLike
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.))
LikeLike
Anyone been able to get this to work with V 7.6.6
i import it, but it does not seem to work.
LikeLike
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.
LikeLike
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.
LikeLike
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?
LikeLike
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!
LikeLike
Perfect! Thank you Andy 🙂
LikeLike
Perfect!!!! Works great, thanks!
LikeLike
Getting error Fail to import…. waste of time
LikeLike
Well, that’s a pithy thing to say.
LikeLike
great job! thank you!
LikeLike
Works like a charm even now. Saved a lot of time on R&D. Thanks Andy.
Do you mind if I use it for Demo’s /Tutorials?
LikeLike
Glad to hear. Feel free to share! Please just give credit where it is due. 😉
LikeLike
Thanks, works like a charm.
It’s missing the keyword “Rule:”, added in Oct 2019. I added it by hand, but maybe add it in the git?
Ref: https://cucumber.io/docs/gherkin/reference/
LikeLike
I have tried this, and it fails to import. I have no idea how notepad++ has changed. Is there anyone that has fixed this?
LikeLike
Hi John. Sorry for the hassle. I just tried a fresh import of my UDL XML file, and it worked successfully with NotePad++ 7.9.1. I also updated the instructions in the article. Could you please retry using this link? https://raw.githubusercontent.com/AndyLPK247/automation-panda-resources/master/gherkin-resources/gherkin_npp_udl.xml
LikeLike
YEAH! it worked. Thanks.
LikeLike
I try to install notepad++ v7.9.5 but getting an error opening file for writing: C:\Program Files\Notepad++\functionList\c.xml
LikeLike
Hello! Did you get this error when trying to install Notepad++ itself or when trying to install the Gherkin language file?
LikeLike
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?
LikeLike
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).
LikeLike