Here’s an example of a scripting-based solution, with Pythonscript.
When you run the script, it walks you through your choices to get the job done:
Step A:
[image: 0egvpsY.png]
Step B:
[image: y1OBCLn.png]
Step C:
[image: oFbCtUt.png]
Here’s the short script, which I call PrefixOrSuffixLines.py:
def POSL__main():
title = 'MODIFY LINES - Prefix or Suffix'
result = notepad.messageBox(
'PREFIX {} lines (the alternative being to SUFFIX ) ?'.format('all' if editor.getSelectionEmpty() else 'selected'),
title,
MESSAGEBOXFLAGS.YESNOCANCEL
)
if result == MESSAGEBOXFLAGS.RESULTYES:
prefix_or_suffix = 'pre'
elif result == MESSAGEBOXFLAGS.RESULTNO:
prefix_or_suffix = 'suf'
else:
return
result = notepad.messageBox(
'Apply {}fixing to EMPTY lines ?'.format(prefix_or_suffix),
title,
MESSAGEBOXFLAGS.YESNOCANCEL
)
if result == MESSAGEBOXFLAGS.RESULTYES:
do_empty_lines = True
elif result == MESSAGEBOXFLAGS.RESULTNO:
do_empty_lines = False
else:
return
user_text = notepad.prompt(
'TEXT to {}fix all {}lines with:'.format(prefix_or_suffix, '' if do_empty_lines else 'non-empty '),
title,
'' # have input box start out empty
)
if user_text == None: return
editor.rereplace(r'(?-s)^(.' + ('*' if do_empty_lines else '+') + ')',
lambda m: (user_text + m.group(1)) if prefix_or_suffix == 'pre' else (m.group(1) + user_text),
0,
editor.positionFromLine(editor.getUserLineSelection()[0]),
editor.positionFromLine(editor.getUserLineSelection()[1])
)
POSL__main()