User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and playing macros
2 posts Page 1 of 1
Let's say I have 15 paragraphs of text. I need to have each begin with:


and end with


How can I do this in one command? So that, rather than selecting each paragraph and then applying, selecting and applying, selecting and applying...fifteen times, I can select all fifteen paragraphs at once, click one thing and each paragraph gets its own open AND close <p> applied?

After selecting the paragraphs

  • press Ctrl+R to open Replace dialog,
  • enter as search string ^([^\r\n][\s\S]*?)(\r?\n)$,
  • enter as replace string <p>\1</p>\2,
  • select option Selected text if not automatically selected,
  • check option Regular expressions,
  • select Perl and
  • press Replace All.
This Perl regular expression replace all in selected text only can be recorded into a macro which is stored in a macro file with other often needed macros and therefore configured to be automatically loaded on startup of UltraEdit. Those macros in a macro file loaded on startup can be executed quickly via the macro list view or by their hotkeys/chords if assigned to the macros.

Code: Select all
Find MatchCase RegExp SelectText "^([^\r\n][\s\S]*?)(\r?\n)$"
Replace All "<p>\1</p>\2"

Please note: The empty line below a paragraph must be really an empty line and not a blank line containing 1 or more spaces/tabs.

Of course an UltraEdit script running same Perl regular expression replace all on selected text added to the list of scripts for quick execution can be used, too.
Best regards from Austria
2 posts Page 1 of 1