Snippets plugin: Difference between revisions
mNo edit summary |
|||
Line 40: | Line 40: | ||
{{tip|text=You can find snippets to import in the [[:Category:Snippets repository]]}} | {{tip|text=You can find snippets to import in the [[:Category:Snippets repository]]}} | ||
{{top}} | |||
=== Snippets usage === | === Snippets usage === | ||
There are two kinds of snippets, insert snippets and replace snippets. | There are two kinds of snippets, insert snippets and replace snippets. | ||
Line 52: | Line 52: | ||
Here is the result: | Here is the result: | ||
[[File:Man2_snippet_insert_result.png|none|frame|snippet insert result]] | [[File:Man2_snippet_insert_result.png|none|frame|snippet insert result]] | ||
{{top}} | |||
==== Replace snippets ==== | ==== Replace snippets ==== | ||
Some snippets make replace in a selected text. Select text before use them! | Some snippets make replace in a selected text. Select text before use them! | ||
Line 63: | Line 63: | ||
*to export your entire snippets file just copy ~/.bluefish/snippets to mysnippets.xml | *to export your entire snippets file just copy ~/.bluefish/snippets to mysnippets.xml | ||
*to export a selection of branches, you have to create a new branch, move wanted branches into it and export the new branch. | *to export a selection of branches, you have to create a new branch, move wanted branches into it and export the new branch. | ||
{{top}} | |||
== Create snippets == | == Create snippets == | ||
Line 86: | Line 86: | ||
[[File:Man2_create_replace_snippet3.png|none|frame|lorem ipsum]] | [[File:Man2_create_replace_snippet3.png|none|frame|lorem ipsum]] | ||
|} | |} | ||
{{top}} | |||
== Edit snippets == | == Edit snippets == | ||
Line 98: | Line 99: | ||
== Show as menu == | == Show as menu == | ||
{{top}} | |||
{{Man2bottom | {{Man2bottom | ||
|prev=Man 2 ch07s06 | |prev=Man 2 ch07s06 |
Revision as of 10:50, 9 January 2010
The snippets plugin allows you to record reusable pieces of code. There are two categories of snippets:
- insert strings
- search and replace patterns
Snippets are organized in branches. The first time you open Bluefish 2 you have no snippets. You have to create them, or import a set of snippets.
- Bluefish 1.3 users
- you can copy your old snippets to Bluefish 2
$ cp ~/.bluefish-unstable/snippets ~/.bluefish/ - Bluefish 1.0 users
- to import your Bluefish 1 Custom menu in snippets you can use Olivier's python script convert_custom_menu_to_snippets.py.
- put convert_custom_menu_to_snippets.py in ~/.bluefish/ directory
- make the script executable: $ chmod a+x convert_custom_menu_to_snippets.py
- run the script: $ ./convert_custom_menu_to_snippets.py > mysnippets.xml
- import mysnippets.xml in your snippets plugin.
- You also can find useful snippets in Snippets repository
Import snippets
The first time you open Bluefish 2 you have no snippets. You have to create them, or import a set of snippets. Right click in the snippets area open the snippets menu.
|
|
Snippets usage
There are two kinds of snippets, insert snippets and replace snippets.
Insert snippets
Snippets are organized in branches (chapters) and possibly sub-branches. In mediawiki branch there is a sub-branche called man bf where are usefull snippets to edit Bluefish manual. The title of the snippet gives an idea of what it does. By moving the mouse over the title of the snippet appears a tooltip giving details.
By double-clicking a snippet is inserted the code at the cursor position in the edit area.
Snippet can use parameters, double-clicking opens a dialog box.
Here is the result:
Replace snippets
Some snippets make replace in a selected text. Select text before use them!
Export snippets
- you can export:
- a branch
- a single snippet
- to export your entire snippets file just copy ~/.bluefish/snippets to mysnippets.xml
- to export a selection of branches, you have to create a new branch, move wanted branches into it and export the new branch.
Create snippets
Branch
Insert strings
lorem ipsum
Search and replace patterns
Edit snippets
Reorder snippets
lorem ipsum