0

How can I wrap text or sentences on HTML file with find and replace (Regex) on TextPad?

For example, how can I change this:

<td align="center">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>
<td align="center">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>

to this:

<td align="center"> <single>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</single></td>
<td align="center"><single>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</single></td>

using the find and replace function in TextPad?

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
gond
  • 1
  • 2
  • Could you be a little more clear with your question? It's very unclear what you're asking. – stjns Mar 11 '16 at 03:35
  • hi I just want to wrapping text with find replace (regex) in TexPad like code above. its difficult to me because I have hundred sentences on my HTML file. – gond Mar 11 '16 at 03:44
  • OK, I understand what you're asking now. I could tell you how to do it in Sublime Text, but I don't use TextPad. I edited your question to give clarity so someone who knows more about TextPad can answer it. – stjns Mar 11 '16 at 04:00
  • How you do that on Sublime Text could you tell me? – gond Mar 11 '16 at 06:45

2 Answers2

0

I cannot answer to TextPad, but I can tell you how to do it in Sublime Text.

There are two things you need to know in Sublime to accomplish what you are trying to do.

  1. The "Find" function, including RegEx and "Find in Selection" tools.
  2. The concept of "Multiple Cursors"

The "Find" tool can be accessed just like in a web browser, by pressing ctrl+f (Windows)

It will open on the bottom of the screen, and on the left side you will see some buttons. If you hover over the buttons you will see a descriptor. One of them is the RegEx search, and another is the "In Selection" button, among others.

When you search, you don't need to try to search for exactly what you will be editing, you just need to find something that always comes before or after what you want. The reason for this will become clear later, just trust me for now.

So in your case, you probably don't need to use the RegEx search. First, select the entire section that you want to search in, then hit ctrl+f (Windows), type in something like <td align="center">, then hit the "In Selection" button. At that point, you should have all the instances of <td align="center"> in your selection highlighted. You could also search for the closing tag of </td> to get the other end.

At this point, you can just step through the document one at a time, but there is a better way: Multiple Cursors.


Multiple cursors is one of the coolest features of Sublime.

Now that you have highlighted every instance of what you're looking for, pressing alt+enter (Windows) will give you a cursor at all those places. You can now use the arrow keys to move the cursors to the exact place you want to insert your text. Once you're there, just start typing! You will see your new text show up in all those places!


Sublime Search and Replace:

https://docs.sublimetext.io/guide/usage/search-and-replace.html

Multiple Cursors:

https://docs.sublimetext.io/guide/usage/editing.html#multiple-selections

Sublime keyboard shortcuts:

OSX: https://docs.sublimetext.io/reference/keyboard_shortcuts_osx.html

Windows: https://docs.sublimetext.io/reference/keyboard_shortcuts_win.html

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
stjns
  • 1,420
  • 13
  • 16
0

You could do this with a macro in textpad...

  1. start recording macro
  2. F5 to find
  3. type >
  4. press return
  5. stop recording macro

Then you can run the macro, there are options on the number of times or repeat until the end of the file.

you can assign keys (configure -> preferences -> keyboard) for step 1 and 5 which makes it easy to action customization as well as playback.

Barry
  • 3,303
  • 7
  • 23
  • 42