Search and Replace Code Between...

Is there a way to label a section of code in a html page and do a "search and replace" in files and replace every instance of code that occurs within that label across files? For example...

<!-- Label TopBar Begin -->
<p>this is some code</p>
<p>code may vary within these tags across many pages</p>
<p>but want to replace whatever is in between these tags with new code...</p>
<!-- Label TopBar End -->

If this functionality does not exist as I describe it, what is the best options for doing this?

7 comments

there is no such feature in Webstorm
Please feel free to file a request for it to youtrack

0

The example I provided is just an example. I am totally open to any creative solution... easy one preferred :)

0

Have you considered using a template system?

Tc

0

Solved... I am new to this forum and am considering switching my web dev to Webstorm. I'm really liking it. It lacks some tools to make it truly usable for me. Instead of waiting for solution from jetbrains, I just wrote a small executable that does what my original post suggested. It loads all html files from project into array, opens each one, checks for label and replaces text between labels in one pass. The ide picks it up as an external change ok even if files are open. You fix the code on one page, copy it, hit the go button and it does a bunch of files in no time. As long as your labels are in place, it seems pretty bulletproof. It's pretty rudimentary, but writing plugins looked like a real pain.

I intend to use it for code blocks that exists on many pages... i.e. topbars, navbars, footers etc. to cut dev time when edits to common elements need to be made. I can't believe that this has not been major issue for users of webstorm! Think about it... one path change in your web navigation and you are opening 15-20 files making the changes by hand... isn't that what a computer is for... to get rid of the repetition and mistakes you make from ADD :)

0

Incidentally... Added to custom tools. Added task to toolbar for quick start inside ide.

0

Tom House, using the same code base I used for replacing labels, could easily be adjusted to create a real templating system identical to Dreamweaver in short order. What this means is that any  new files created from master template would have all the labels in place for code that may change across many documents. Any edit to master template would equally update all files built from template. Instead of using WebStorms default templating system, you would just use small exe that could be added to toolbar etc as external program and appear totally seamless... I think!

0

I am glad you found a solution that fits your needs.

One nice thing about these tools, is that they will allow you to use custom solutions like you have built.

Myself, I prefer existing solutions by handlebars, jade, and other temp playing engines that are already in use.

I find that the existing support for these engines outweighs the flexibility of my own custom application.

Good luck with your solution.

0

Please sign in to leave a comment.