Jim Campbell
jwcampbell@gmail.com
Sindhu S
sindhus@live.in
Utiliser des fragments de code pour insérer rapidement les morceaux de texte fréquemment utilisés
Vincent Untz
vuntz@gnome.org 2006.
Jonathan Ernst
jonathan@ernstfamily.ch 2006.
Philippe Lefevre
ph.l@libertysurf.fr 2006.
Christophe Bliard
christophe.bliard@trux.info 2006.
Claude Paroz
claude@2xlibre.net 2007-2011.
Bruno Brouard
annoa.b@gmail.com 2011.
Luc Pionchon
pionchon.luc@gmail.com 2011.
Alain Lojewski <allomervan@gmail.com>, 2011-2013.Alexandre Franke
alexandre.franke@gmail.com 2013.

# Fragments de code

Fragments de code permet une insertion aisée de morceaux de texte fréquemment utilisés dans vos fichiers. Par exemple, un fragment de code HTML pour l'étiquette `<img>` insère les parties ouvrante et fermante de l'étiquette mais aussi les emplacements fixés où vous pouvez saisir les attributs de l'image. Cela peut accélérer et vous faciliter l'écriture du code.

# Enable Snippets Plugin

To enable the Snippets plugin:

Select gedit Preferences Plugins.

Select Snippets to enable the plugin.

# Browse Snippets

To browse available snippets:

Select Tools Manage Snippets.

Make sure the syntax is set appropriately. The status bar at the bottom of the gedit window will show the current language setting. This language setting is what allows gedit to insert the proper snippets. Gedit will normally detect the language or syntax of the file that you're using, but sometimes you may need to set it.

Dans cet exemple, le langage est défini à HTML.

Browse the snippets that are available for your language or syntax.

# Using Snippets

To insert a snippet into your current document:

Type the desired snippet name anywhere in your current document.

Press Tab to insert the snippet associated with the input term.

# Snippet Example Usage

For example, if you have set the syntax to HTML, type `head` , and press the Tab key. The text would have auto completed into a snippet as:

<head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Page Title</title> </head>

# Adding Snippets

You can add new Snippets that work either globally (that is, they are language agnostic) or only in a particular syntax.

Select Tools Manage Snippets.

From the Manage Snippets sidebar select the desired syntax and click on the "+" button to list existing snippets for the selected syntax.

To add a snippet that works globally (that is, when no particular syntax or language has been set for the document), select Global from the Manage Snippets sidebar.

To add a new snippet, click on the "plus" icon in the Manage Snippets sidebar.

Input a name for the new snippet. The name of the snippet can be different from the snippet you want to add.

Under the Activation section, you must input a term for the Tab trigger: textarea. You will be using this term to insert your snippet.

If you wish to insert a snippet with a keyboard shortcut, then click your mouse pointer on Shortcut key: textarea and press the desired combination of keys. Once you have pressed and released the keys, the keyboard shortcut will be set.

Under the textarea for Edit:, input the desired text for the snippet. You may use `${n}` to indicate variables, where n is replaced with a number that represents the numerical order of variables included.

# New Snippet Example

Consider you have created a snippet with the term greetings in Tab trigger:. The Edit: textarea contains:

<greetings>Hello ${1:wonderful}${2:amazing} world! </greetings>

You can insert this snippet by typing greetings in the document and pressing the Tab key. The following text snippet will be inserted:

<greetings>Hello wonderfulamazing world!</greetings>

The words "wonderful" and "amazing" can be retained or deleted depending on your choice of usage. To do so, press Tab to choose between "wonderful" and "amazing" and press Del to delete the least preferred option.