About two weeks ago Version 1.0.0 of the Power Query M Language extension for Visual Studio code was released:
Here’s a link to it in the Visual Studio Marketplace. Per the overview page the initial release includes colorization, auto-closing, and surrounding support.
Here’s a simple example of an M query in VS Code (with the extension):
Once you have the extension installed you can copy an M query from the Advanced Editor window in Power BI Desktop and paste it into a new file in VS Code. You can then just save the file as a .m (per the MyPQ.m example), .M, .pq, or .PQ file. Alternatively, you may already have an M/Power Query expression saved from Notepad as an M file. If so, you can just open the file from within VS Code.
Note: You may have to update to the latest version of VS Code to install the extension.
The bottom line is we finally have some level of development support for M queries. Previously the best (only) option has been to create an M editor with Notepad++ as described in this blog.
Given the importance of M to Power BI, SSAS 2017+, and other Microsoft products I’ve been hoping for at least basic editor support like this within Power BI Desktop and/or SQL Server Data Tools. Maybe this is still in the works for SSDT for VS 2017 but I’d be very surprised and I haven’t heard anything for PBI Desktop. Clearly DAX editing/dev has been a priority for PBI and SSAS so hopefully M will get similar support in 2018.