[wingide-users] [scripting] overwriting selection

Wingware Support support at wingware.com
Mon Jan 21 10:26:03 MST 2008

Luc Bourhis wrote:
> editor.GetSelection() returns the current selection but how would I 
> overwrite it with a string in a script?

Text modification is done through the document object.  I think you want 
to use something like the following (untested) code:

   doc = editor.GetDocument()
   start, end = editor.GetSelection()
   doc.DeleteChars(start, end)
   doc.InsertChars(start, text)

You also may or may not want to set the selection after inserting the 
new text.



More information about the wingide-users mailing list