Reputation: 2435
In the web project I have been working on, we have string literals all over like
<div class="title">This is Title</div>
<div class="text">This is some text<div>
In order to make the application multilingual, I need to replace all these literals to some helper methods:
<div class="title">@TranslationHelper.Translate("This is Title")</div>
<div class="text">@TranslationHelper.Translate("This is some text")<div>
I want to create a custom shortcut (e.g CTRL + ALT + M) either through Resharper 8.0 or Visual Studio 2012.
When I select the text I want to transform and press the shortcut I defined, Visual studio should replace the selection with the format I defined.
How do I do that?
Upvotes: 1
Views: 180
Reputation: 17719
You can use Resharpers Surround With
feature to acheive this. First open the Template Explorer
Resharper -> Template Explorer
then click New Template:
Enter your desired string in the template editor and save (Ctrl-S)
Now place your cursor in the desired text. On another note you can use Resharpers Extend Selection
feature to quickly select the text (Shortcut is Ctrl-Alt-RightArrow)
Once the text is selected choose press Ctrl-E,U (Resharper Surround with)
Click More where you can select your new template and ensure you add it to the quicklist so its added to the list for next time
Upvotes: 2