Using Code Snippets
Web designers commonly reuse code in several pages. Whether you're reusing a single line of code or a code block, you need to avoid typos at all costs. Code snippets can prevent typos and add a high degree of convenience to code reuse.
To insert a code snippet into your page, switch to Code View and press Ctrl-Enter. Select the desired code snippet from the list and press Enter, as shown in Figure 3.17, and it will be added to your page automatically. You can also double-click the code snippet and it will be added to your page.
Figure 3.17 Code snippets can be added easily by pressing Ctrl-Enter while in Code View.
To add, delete, or modify existing code snippets, select Tools, Page Editor Options and then click the Code Snippets tab in the Page Editor Options dialog, as shown in Figure 3.18.
Figure 3.18 Code snippets make reusing code convenient. Expression Web 3 comes with plenty of existing snippets.
You can add a new code snippet by clicking Add and entering the required information. You can control where the insertion point appears after inserting the snippet by adding a pipe symbol (|) to the snippet code. If you add two pipe symbols, all code between the two pipe symbols will be automatically selected when the snippet is inserted.
When you add your own snippets, they are stored in an XML file located in the AppData\Roaming\Microsoft\Expression\Web 3\Snippets folder in your profile directory. To move your snippets to another machine or back them up (something I strongly recommend), you can simply back up the Snippets.xml file in the Snippets folder.