If you are working with DAX and do more than single-line statements, you will frequently find yourself wishing for a powerful editor with proper syntax highlighting. Below I explain how to use Notepad++ for that purpose. While I use DAX mostly in Power BI, it of course works just as well with other environments.
If you prefer watching over reading, check out the short video below. In it, I use DAX as an example. But it works just the same for M, of course.
Get the Files
Please fill in the short form below. After submitting the form, you will be taken to the download page. You will also receive an email with a direct download link.
5.0 – June 13, 2023
- Tested on version 8.5.3 (64 bit)
- Added new DAX functions released in Jan-May 2023
This guide is based on the 64-Bit Notepad++ version 8.5.3. You can always download the latest version of Notepad++ here.
Follow the instructions below to
- enable syntax highlighting
- enable auto-completion
- modify the syntax colors to your liking
The same process works with the files for M (PowerQuery) over here.
Extract the received ZIP archive and open the folder location in your file explorer. Make sure there is an “m.xml” file and an “AutoComplete” folder.
I am aware that the screenshots show DAX, just select M instead. The process remains the same.
To import the file,
- start Notepad++,
- click on Language, Define your Language, Import,
- navigate to the file and click Open.
- Close the Define your Language dialog.
Make sure to click Language again and select DAX from the list. Only then it will be applied to the file you opened.
If you don’t see DAX in the language menu right away, you may have to restart Notepad++.
This will give you syntax highlighting. If you want to have the auto-complete functionality, you need to
- navigate to the extracted folder
- enter the “AutoComplete” folder
- copy the file “m.xml” from the AutoComplete folder to the folder “autoCompletion” inside the Notepad++ program directory. In my case this is “C:\Program Files\Notepad++\autoCompletion“
- You will get a warning, requiring Administrator permissions.
- Confirm the warning and restart Notepad++
Modifying The Colors
I tried to pick colors that work equally well with the light and dark theme of Notepad++. However, colors that work well for me, might not be that great for you.
Fortunately, you can adapt them very easily. In Notepad++ click on Language, User Defined Language, Define your Language.
Select M from the User Language drop-down:
Use the tabs to find the elements you want to modify:
- Folder & Default
- Comment & Number
- Operators & Delimiters
Click on the Styler button and adjust any attributes you want
- Foreground color
- Background color