A snippet is a bloc of code which can be automatically generated. To add a snippet, just press Ctrl+Space in one of the TM1 process tab, and then type snippet or the name if you know what it is.
In this example we choose the snippets: "While loop through dimension":
Once the snippet has been inserted use the tab key to navigate to each placeholder to update the values. When one placeholder is used in multiple locations in the code, you just need to overwrite one location and all the other locations will be updated automatically: