I just filed two enhancement requests in bugzilla at Eclipse.org:
245788 Add a template variable ${selection} and allow Surround With action to deal consider it.
245790 Add a template variable ${clipboard}
The jist of the enhancement is that two new template variables should be added:
${selection} - this is replaced by what ever was the selection in the editor at the time of template insertion was invoked. Note that this requires a template invocation machanism that does not destroy the selection in text editor.
${clipboard} - this is replaced by the text content of the the clipboard.
Here is a use case:
template name: hyperlink
template pattern:
<a href="${clipboard}">${selection}</a>${cursor}
and with text http://www.google.com/ in the clipboard and the text
Google|
selected in the Eclipse editor.
Invoking the hyperlink template using the Surround with... action yields:
<a herf="http://www.google.com">Google</a>
Granted this would have been easy to type but imagine a complex URL copied into the clipboard from the browser address bar in place of "http://www.google.com/".
Please vote on the enhancement if you like this idea.
245788 Add a template variable ${selection} and allow Surround With action to deal consider it.
245790 Add a template variable ${clipboard}
The jist of the enhancement is that two new template variables should be added:
${selection} - this is replaced by what ever was the selection in the editor at the time of template insertion was invoked. Note that this requires a template invocation machanism that does not destroy the selection in text editor.
${clipboard} - this is replaced by the text content of the the clipboard.
Here is a use case:
template name: hyperlink
template pattern:
<a href="${clipboard}">${selection}</a>${cursor}
and with text http://www.google.com/ in the clipboard and the text
Google|
selected in the Eclipse editor.
Invoking the hyperlink template using the Surround with... action yields:
<a herf="http://www.google.com">Google</a>
Granted this would have been easy to type but imagine a complex URL copied into the clipboard from the browser address bar in place of "http://www.google.com/".
Please vote on the enhancement if you like this idea.