Pages

Friday, February 10, 2012

Inserting code snippets in the AX 2012 X++ editor

In the AX 2012 X++ you can quickly insert fragments of code to avoid tedious typing, such as typing for a loop.

To insert a snippet, you must enter the snippets alias (which is usually the first symbol of the code), and press tab. For example, typing switch followed by tab, gives you this snippet:
switch ()
{
    case :
        break;

    case :
        break;
}

I don't have a clear picture of all the available aliases, but these work:
  • switch
  • for
  • do
  • while
  • try
In the regular Visual Studio editor you can add your own code snippets. I haven't figured out yet, if this is also possible for the X++ editor.

UPDATE: Brandon, a fellow blogger, wrote a great blog post about these scripts: AX 2012 - xppSource Exposed: Inserting code snippets

4 comments:

luetter said...

Hi,
its possible to use the parm snippet to. With this snippet, its open a paramter window to enter the edt and
variable name.

Best Regards,

Mathias

Max Belugin said...

It is just an execution of templates from EditorScripts class.

You can add yours, if need

Palle Agermark said...

Ah, cool.

Thanks for the tip!

Palle Agermark said...

Thanks, Mathias. That'll be a great time saver.