One of the nice things about my sendkeys
plugin is the fact that it's easy to add new "special keys." I have a macro to create a link in Notepad++: it takes the selection, wraps it in <a href=""></a>
and places the insertion point between the quotes so I can start typing the link.
I added two things to sendkeys
to make that possible: {selection}
, which remembers the original selected text and inserts it, and {mark}
, which records the location of the insertion point and sets the selection there after the string is inserted. Thus, '<a href="{mark}">{selection}</a>'
accomplishes the same thing and I can use it in my home-grown text editors.
<input class=text /> <input type=button class=test value="Try It" />
$('input.test').click(function(){ $('input.text').sendkeys('<a href="{mark}">{selection}</a>'); });