You've been so helpful, I've got a bunch of stuff working how I want it now!
One further question: If I want to extract text that I've selected in the document, would I still use view.sel() somehow? I'm assuming it would be some function in the view class anyway. I've been looking through the plugins and the forums/docs and I can't seem to find an example. (I think this should just about finish up all the questions I have )
Thank you all once again for your help with this!