pgAdmin 1.8 online documentation
Query Tool Macros
Query Tool Macros enable you to execute pre-defined SQL queries with single key press. Pre-defined queries can contain the placeholder $SELECTION$. Upon macro execution the placeholder will be replaced with the text current selected in the SQL pane of the Query Tool.
To create a macro, select the Manage Macros option from the Macros menu on the Query Tool. Select the key you wish to use, enter the name of the macro, and the query, optionally including the selection placeholder, and then click the Save button to store the macro.
To clear a macro, select the macro on the Manage Macros dialogue, and then click the Clear button.
To execute a macro, simply press the appropriate shortcut keys, or select it from the Macros menu.