What’s New in NAV 2016: Code Editor

Three years ago I was doing a presentation about something or other about NAV at a non-NAV conference. That’s in front of normal developers. And you can imagine what their impression was of the state of the technology when, in front of a couple of hundred mostly C# developer, I opened the C/AL editor.

I don’t need to be concerned about that anymore, because Microsoft Dynamics NAV 2016 comes with a new code editor, which comes with a number of features the whole NAV community way hoping for since I remember. And I started forgetting a long time ago.

Namely, we now have:

  • Proper syntax highlighting
  • Line numbers
  • Change indicators
  • Auto-complete intellisense style. Ish.
  • Syntax tooltips
  • And – hold your seats! – undo!

Let’s take a look at each of those.

image

Here, the first three points are obvious. Syntax highlighting properly shows keywords, operators, strings, comments… even block comments are properly interpreted, so the caveat “do not use block comments because they do not show properly in the syntax” loses ground. You should still not use block comments, but at least not because of syntax highlighting (cough, poweshell compare, cough).

The second obvious thing is that we now see line numbers. Not that it helps too much by itself, but the code is now easier to refer to.

Then, change indicators are absolutely lovely. While you are editing, the lines you edited are marked with yellow, and as long as you didn’t save the object, they will stay yellow. When you save, the line indicators will turn green:

image

At this point, I’ll file my first complaint. When you close the editor, without closing the object (e.g. in the table or page designer, you go back from code editor to layout or field designers) and then return to the code editor, the change indicators are gone. Too bad, but still this is a welcome feature.

Autocomplete is a great replacement for the Symbol Menu (which is still there) and it allows you to quickly select among the possible operators, keywords, variables, constants, functions, members, etc.

For example, on a record I see available fields:

image

You can quickly tell the type of symbol, such as fields from functions, by observing the icon. Okay, in all honesty, I don’t know what the key icon means as opposed to that green boxy thing. They are not keys, they are not flow fields, so what exactly are they? If you know for a fact – please share.

The autocomplete feature is invoked by pressing Ctrl+Space just like in Visual Studio, and it filters as you type. Pressing key up or down allows you to select a symbol, and pressing Enter completes the entry. Sweet.

There are a couple of problems, though. First, the good old Symbol Menu allows you to see all the symbols, but won’t allow you to complete code. Pressing Enter or doubleclicking a symbol there won’t put it into your code. That’s a pity. And probably a bug.

The other problem is about .NET. Any .NET variables are autocompletable on the first level only. After you enter . after a .NET object, you’ll see the list of its members, but if a member is .NET type, entering another . will not show the member’s members:

imageHaving full .NET awareness would be really good, and while this can’t be classified as a bug, it would be a welcome feature.

Syntax tooltips are great, and they show you how to call a function or invoke a method:

image

The tooltip pops up the moment you open a parenthesis and shows you the arguments of the function you are calling. Unfortunately, it doesn’t work with overloaded methods, so it’s another thing to put on my wish list.

And finally, last, and definitely not the least, is undo. Whatever changes you make to code, you can undo them. I don’t know if there is a number of changes that are undoable, but from all I can tell – there isn’t one. Undo only works until you close the code editor, which is okay for codeunits. However, if you are editing a table, or a page, make sure you don’t close the code editor when switching from code and table/page/report/… designer. If you close the editor, the undo history is gone. Still, I won’t whine about this. We lived without any undo forever, so this little change is the most welcome change and one that will – I am sure – save thousands of hours for developers worldwide.

It was a long wait, but having it in 2016 is better than having it never. Good job, Microsoft!

Vjeko

Vjeko has been writing code for living since 1995, and he has shared his knowledge and experience in presentations, articles, blogs, and elsewhere since 2002. Hopelessly curious, passionate about technology, avid language learner no matter human or computer.

This Post Has 25 Comments

  1. Sergio Carbajo

    Good article. Could this be the biggest WOW moment of the event? I have been trying it and now I would like to know the purpose of F5.. Any idea?

      1. Koubek

        Yes, you can use old editor as well. Just run finsql.exe with “useoldeditor=Yes”.

        1. Vjeko

          Thanks for being quicker 😉

        2. Vincent (.NET developer)

          WHY do you want to use the old editor?
          As a Visual Studio developer myself, this new editor in NAV2016 is heaven!

          And @Vjeko: Thanks for the great posts! I hope we can chat at the Techdays in Antwerpen

          1. Vjeko

            I also don’t understand why would anybody want to use the old editor. There are still bugs in the new one, but undo alone makes me never shed a tear for the old one. Catch me @TechDays, it’ll be a pleasure.

          2. Johannes Sebastian

            If you re-read my post I’m sure you will be able to find some sarcasm in there 😉

  2. Koubek

    You can see .Net ENUMs` values as well now (including C/AL Symbol Menu). But the comparison (IF (var = var.EnumValue) THEN;) does not work in this way (or at least I can not).

    1. Vjeko

      You could see .NET enum values in the Symbol menu since version 2013, so that’s not a new feature. Also, comparing .NET values with equality operator does not work. You must always do if var.Equals(var.EnumValue) and you are good to go.

      1. Koubek

        Thanks…

  3. Johannes Sebastian

    Very nice.

    All in all, with all these news I can conclude that MS has overcome all the technology/platform changes and are now able to focus on the app and partner experience.
    MS really focuses on NAV now.
    AX does’nt get all the ressourses anymore! 🙂

    1. Vjeko

      Well, AX never got all the resources – they got a lot, but not because Microsoft didn’t care about NAV. Not at all. AX is, as Mark Brummel once put it nice, “a bug farm”. Maybe it provides more process fit for bigger companies, but that’s all. Technologically, NAV has been ahead for a while, and with the latest additions to the stack – it’s way ahead. My opinion – Microsoft wasn’t covering NAV with tough marketing because it was selling well. Microsoft has put marketing focus on AX because it didn’t sell all that well. Just my two cents, I may be totally wrong. But I am sure that NAV is going to rule this game for time to come.

  4. Mark van den Hurk

    All these years coding in notepad.. We finally got enriched.. Good work MS.. We are getting closer to that holy grail moment..

  5. Mark van den Hurk

    On that note.. We should pay respect to the community and last but not least thanks the MVP’s for pushing MS in this direction..

    1. Mark van den Hurk

      And sorry for overloading your blog Vjeko, but you have one happy chap here..

      1. Vjeko

        No worries, Mark! Make yourself at home 🙂 Thanks for comments.

  6. mrserious95

    Have you also seen what happens when you hover or Ctrl + K + I on variables, especially of subtype Record.

    1. Vjeko

      Yes, I have – a good point! It would be nice if it was more interactive. But, it’s great – especially for records.

  7. Mathias Leprince

    hello,
    a nice feature also : the zoom.
    You can zoom in/out the code (ctrl+wheeling). Useful for large codeunits

    1. Vjeko

      Wow, great tip, Mathias! Thanks a bunch!

  8. Weidmann

    Does setcurrentkey( shows all existing Keys for an object? If F5 is not working, you have to add a key on the old (Pre 2013) Way ;(

  9. Miguel

    It would be great for our eyes that black background color will could be an option

Leave a Reply to Johannes SebastianCancel reply