# R Code Snippets

R code snippets are predefined script templates that can be submitted to a running R console. The script template supports Eclipse variables which are substituted by their concrete value before the code is submitted to the console.

### Define Snippets

R code snippets can be configured in Window > Preferences at R > Run/Debug > R Snippets (Open)

The user can add, edit and delete the R snippets using the buttons at the right side. It is also possible to exchange templates between workspaces using the export and import buttons.

In the edit dialog the user can change the description and pattern of the R snippet. The content assist (`Ctrl + Space`) and the button "Insert variable..." helps adding variables to the template pattern.

#### Key bindings

The preference page General > Keys allows to assign keyboard bindings to the submit command for each R snippet.

Note that if the command for a newly created R snippet is missing on this page, it is required to close and reopen the preferences dialog.

### Run Snippets

#### Commands

| Name | Description | Availability
--- | --- | --- | ---
| Run R Snippet (...) | Submits a specific code snippet to the currently active R console. Note: the pull down/sub menu shows only the R snippets which are valid at the current context (e.g. view and selection). | Main toolbar (pull down menu) Context menu (sub menu) Global command
| Run Last R Snippet | Submits a the last submitted code snippet to the currently active R console again. | Main toolbar Global command