Context
We can define snippets as regions of reusable code. Snippets have two exciting sides: use other people snippets and create your own snippets. The potential and simplicity of snippets make them a great tool.
The subject of this post is show an interesting thing: how to create a pattern snippet and use it later. If you want to review NAV patterns visit this link: https://community.dynamics.com/nav/w/designpatterns
Warning: I am an absolute beginner in VSCode and far away from doing something strong with this tool, advanced users will be bored about this post. I use them in very basic mode and there are a lot of more features to use: add placeholders, regular expressions and later package and publish snippet.
Create the pattern
In the example we are going to create part of this pattern:
https://community.dynamics.com/nav/w/designpatterns/125.journal-template-batch-line
We only will create the snippet for Journal Batch table.
Open VSCode and go to File/Preferences/User Snippets:
Choose AL language and the editor open the "al.json" file. Then you put there the snippet code:
Some comments about this snippet:
- We must write the content of the snippet code in body section. Each line must be delimited by double quote, or I think so, and ended by colon.
- Json is (very) case sensitive.
- The scape character is "\". You need it for write the double quote within the line.
- The character "$" at the beginning of a word ($Master) means a variable or tabstop. We will see bellow that this is very interesting.
Using pattern.
When editing VSCode, you can type the snippet prefix:
Then it carry all this code:
Notice, that if you select and replace text "Master" by "Palet", automatically replace it in all the "Master" instances.

Like
Report
*This post is locked for comments