As outlined here: http://docs.kde.org/stable/en/applications/kate/advanced-editing-tools-scripting.html When writing a script to accompany a Snippet, calls to functions in the View API don't appear to work. Specifically, no string is returned from view.selectedText(). Reproducible: Always Steps to Reproduce: 1. With Snippets plugin installed, create and name a new Snippet. 2. Enter: ${fn`getSelectedText`} as the text in the Snippet tab. 3. Enter: function getSelectedText() { return view.selectedText(); } as the text in the Scripts tab. 4. Apply the changes. 5. Select some text and run the Snippet. Actual Results: Nothing. Seems to return null. Expected Results: The text selected in the main view should be returned. This function used to be provided within Snippets by the ${selection} keyword, but this no longer functions either. It's important for writing Snippets that surround the selected text with HTML elements, for example.
I can confirm this behaviour. inserting e.g. %{date} works, but %{selection} does not work. This behaviour is critical since one often wants to write snippets that "surround" an existing block of text.
Fixed in 5 with changes to the snippets engine. Use ${selection()} to get the selected text.