2016-10-03 21 views
0

我試圖使用Visual Studio宏編輯器一個Visual Studio宏代碼格式逗號第一

https://visualstudiogallery.msdn.microsoft.com/d3fbf133-e51b-41a2-b86f-9560a96ff62b

它允許用戶編寫宏在javascript來驅動IDE。我希望能夠做的就是編寫格式文本

public void Foo(
int i, 
int b, 
int c) 

public void Foo 
(int i 
, int b 
, int c 
) 

這個宏應該是很平凡的,如果我只知道命令做到以下幾點。

(1) Move the cursor to the next matching character, and detect if it is not found 
(2) Insert a carriage return 
(3) Join lines together 

我已經得到儘可能

dte.ExecuteCommand("Edit.Find"); 
dte.Find.FindWhat = ","; 

但希望有人會知道他們的DTE命令優於一

回答

1

(1)將光標移動到下一個匹配的性格,檢測是否未找到:

DTE.Find.FindWhat = ","; 
DTE.Find.Target = EnvDTE.vsFindTarget.vsFindTargetCurrentDocument; 
if (DTE.Find.Execute() == EnvDTE.vsFindResult.vsFindResultNotFound) 
{ 
// not found 
} 

(2)插入回車符:

DTE.ExecuteCommand("Edit.BreakLine"); 

(3)加入線一起:從開始或者從線的端部稱爲時

Edit.DeleteBackwardsEdit.Delete可以刪除換行符。

(注意:這是我的Visual Commander擴展的語法,但也適用於Visual Studio宏編輯器。)

相關問題