With VIM, I can use Tim Pope's wonderful vim-surround plugin to place the cursor within a string and issue the ds"
keyboard sequence in order to unquote it. How can an equivalent be achieved in VS natively or with Resharper?
VIM + vim-surround:
"aaa|aaaaa"
---> pressds"
--->aaa|aaaaa
In VS, I know I can use a regex Find/Replace query with:
|"aaaaaaaa"
---> pressCtrl+H
---> ...Find:
"(.+?)"|'(.+?)'
Replace with:$1
... press
Alt+R
to replace next, and we have:aaaaaaaa
(the next matching quoted string is selected)
... but I'd like to turn it into a macro triggered by a keyboard shortcut.
I installed the Macros for Visual Studio extension from the Visual Studio Gallery, but this doesn't register interactions with the Find/Replace dialogue when recording a macro.
I tried writing a Macro myself based on Using Search and Replace Macros in Visual Studio, but it doesn't work. I'm getting errors that e.g. vsFindTarget
and vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
are not defined.
Here's my failed macro code:
dte.ExecuteCommand("Edit.Replace");
dte.Find.FindWhat = "\"(.+?)\"|'(.+?)'";
dte.Find.ReplaceWith = "$1"
dte.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
dte.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
dte.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
dte.Find.Action = vsFindAction.vsFindActionReplace
dte.Find.Execute()
I looked at Microsoft's documentation mentioned in this SO answer, but I'm getting issues as above. Makes me think that Macros for Visual Studio extension has it's own API on top of the native VS API, or (most likely) I'm just not getting it.
Any help would be appreciated. Thanks!