File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ This is a collection of useful Komodo macros.
9
9
- [ PHPDoc and JSDoc] ( #phpdoc-and-jsdoc )
10
10
- [ Incremental Numbering] ( #incremental-numbering )
11
11
- [ Copy Find Results] ( #copy-find-results )
12
+ - [ Automagic Snippets From Text] ( #automagic-snippets-from-text )
12
13
- [ How to Install] ( #installing )
13
14
- [ Contributing] ( #contributing )
14
15
@@ -46,6 +47,13 @@ There can be two find results pane opened - this only works on the first one.
46
47
47
48
See the [ code] ( find_results_copy.js ) .
48
49
50
+ ### Automagic Snippets From Text
51
+
52
+ Create a snippet from selected text, add a name and automatically open properties
53
+ to add keybinding.
54
+
55
+ See the [ code] ( automagic_snippets_from_text.js ) .
56
+
49
57
## Installing
50
58
51
59
Create a new macro in your Komodo toolbox and copy/paste the contents into the
Original file line number Diff line number Diff line change
1
+ // Create a base snippet with the selected text
2
+ scimoz = ko . views . manager . currentView . scimoz ;
3
+ var snip =
4
+ ko . projects . addSnippetFromText ( scimoz . selText ) ;
5
+ //create a date to be used as a unique name on the snippet
6
+ var d = new Date ( ) ;
7
+ // Create a unique default name string
8
+ var defaultName = "New Snippet - " + d . toLocaleTimeString ( ) . substr ( 0 , 8 ) . trim ( )
9
+ // Ask for a name or provide the unique default
10
+ var name = ko . interpolate . interpolateStrings ( "%(ask:Snippet Name: " +
11
+ defaultName + ")" )
12
+ // Assign the name to the snippet name attribute
13
+ snip . name = name ;
14
+ // Open the snippet options to set a keybinding
15
+ ko . projects . snippetProperties ( snip ) ;
You can’t perform that action at this time.
0 commit comments