This is quick answer and should get you going.
[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
internal sealed class SelectionCreatio : IWpfTextViewCreationListener
{
public void TextViewCreated(IWpfTextView textView)
{
textView.Selection.SelectionChanged += (sender, args) =>
{
// do your stuff.
}
}
}
Mark your VSPackage as a MEF component and you're good to go.