Don't worry, fixed it myself. Was related to TextSelection and Resharper being clever. When assigning TextSelection.Text, Reshaper try to insert the correct matching brackets. The right use for TextSelection is to use the Insert method. testSelection.Insert(val, (int)vsInsertFlags.vsInsertFlagsInsertAtStart);