public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "CleanSpace.Connect.CleanSpace") { try { TextSelection txtSel = (TextSelection) _applicationObject.ActiveDocument.Selection; TextDocument d = (TextDocument)_applicationObject.ActiveDocument.Object("");
trs//这个需要定义,vs已经关了,多注释了一行,自己修改把, 本来直接可以替换成''字符串的,但是不知道为什么报错,所以
//先替换成}~{然后在替换成''
}catch(Exception ex) { MessageBox.Show(ex.Message); } return;}}}if (!d.Selection.FindText("}~{",(int)vsFindOptions.vsFindOptionsNone)) { d.ReplacePattern("^[:b]*\n", "}~{", (int) vsFindOptions.vsFindOptionsRegularExpression, ref trs); d.ReplaceText("}~{", "", (int) vsFindOptions.vsFindOptionsNone); handled = true; }else { MessageBox.Show("文档中有字符}~{"); }
vs2008 插件 去空行
最新推荐文章于 2024-07-09 17:40:30 发布