vs2008 插件 去空行
来源:互联网 发布:广州数控车床编程软件 编辑:程序博客网 时间:2024/04/30 14:13
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已经关了,多注释了一行,自己修改把, 本来直接可以替换成''字符串的,但是不知道为什么报错,所以
//先替换成}~{然后在替换成''
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("文档中有字符}~{"); }
}catch(Exception ex) { MessageBox.Show(ex.Message); } return;}}}