So after going through the information on scripting I realised that it was not possible to do this in the script as there was only GetText and SetText available in the cbEditor class.
Therefore I have gone through (the slightly larger than expected) pain of writing the plugin in C++ code. I have the basics working but still have some generalisation work to do. Given the lack of responses from anyone else here I assume that this feature is not widely required from the community.
However, I would like to request (and I expect I'm posting in the wrong place) that the script API of cbEditor is extended a little further to include reading calls like GetCurrentPos(), GetSelectionStart(), GetSelectionEnd(), etc and writing calls like ReplaceSelection(), etc.
There may well be a very good philisophical reason why this is not done currently, in which case you can continue to ignore this post