More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Sunday, 3 November 2013 12:16:52 PM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 523

From Visual Studio 2010, macros are not longer included. Without macros, the traditional multiline find and replace macro cannot be integrated with Visual Studio. Apart from installing a macro plug-in, there is an easier way to update duplicate blocks of text in multiple files from Visual Studio 2013, 2012 and 2010, thanks to Sync Block Edit from Sergey Vlasov Studio. I searched Visual Studio add-ins, extensions and tools and found this one is simpler. I think it's easier than "Find and Replace multiple lines using regular expressions" in this instance (updating duplicate blocks), at least for some developers.

How to use it:
1. select a text block;
2.
  • click Sync Create Block from Visual Studio toolbar to bring up Create Block dialog;

  • define BEGIN and END signatures;

  • select scope or target: current document, all open documents, project or solution;

  • press Create button, the BEGIN and END signatures will be inserted to the selected files.

3. make a change to a file;
4.
  • select the block with the BEGIN and END signatures and click Sync Update Block from VS toolbar to show Update Text dialog;

  • select the target as mentioned in step 2;

  • press Update button and then the job is done - all the blocks are updated.

Edited by user Sunday, 17 November 2013 11:31:40 AM(UTC)  | Reason: Not specified

Sponsor
hong  
#2 Posted : Sunday, 17 November 2013 12:28:03 PM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 523

Find and Replace multiple lines in multiple files using regular expressions in Visual Studio

To find and replace duplicate blocks in multiple files, we can use Sync Block Edit as mentioned above (see previous post). However, this approach won't be able to handle blocks with slight variations. In this case, regular expressions would be more flexible and powerful. For example, I replaced Facebook like button code blocks from hard-coded static URL using iframe to dynamic URL using Javascript. Each old block was different because it referred to a different URL.

Find what:
Code:
^.*<iframe id="I2" allowtransparency="true" frameborder="0" name="I2"(.*\n)(.*\n)(.*\n)(.*\n)

i.e. search from the beginning of the first line to the last line of the block

Replace with:
Code:
<div class="fb-like" id="fb2" data-href="http://www.bettereducation.com.au" data-send="true" data-layout="standard" data-width="266" data-show-faces="false"></div>\r\n<script type="text/javascript">\r\n    var sUrl = window.location.href;\r\n    document.getElementById('fb2').setAttribute('href', sUrl.replace("http://www.", "http://"));\r\n</script>\r\n

i.e. use \r\n to append lines.

Edited by user Sunday, 17 November 2013 12:30:23 PM(UTC)  | Reason: Not specified

Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.