Feature request: Modify Lines dialog for adding prefix/suffix to lines
-
I am using Notepad2 too and I find the Modify Lines dialogue very useful since I’m using it a lot.
“Edit -> Block -> Modify Lines…”You can use it to quickly add a prefix or suffix (or both) to the selected lines. Very useful stuff indeed.
I would like to place a feature request to implement this, if not in the main Notepad++ program, then in a plugin.
-
Here’s a screenshot with this dialog:
http://oi65.tinypic.com/33asdht.jpg
OR
http://es.tinypic.com/r/33asdht/9 -
So in Notepad++ there are at least a couple of ways to prefix a block of lines:
#1
-
get a column caret (a zero-width rectangular selection) in column 1 (some ways to do it: Alt+Shift+arrows, Alt+Lclick+drag with mouse, there are others…)
-
type the text you want…it is added at the start of every line
#2
- do a regular expression replacement for
^with the text you want to prefix every line with
There are also a few ways to add a suffix, one is native and one uses a plugin:
#1
- do a regular expression replacement for
$with the text you want to suffix every line with
#2
- get a column caret (a zero-width rectangular selection) in column 1 and, using the Better Multiselection plugin press the End key – you will now have a caret at the end of each line and you can go ahead and type or paste your desired text
Anyway, here’s how to do a proper Feature Request: https://notepad-plus-plus.org/community/topic/15741/faq-desk-feature-request
-
-
Thanks for your reply.
Indeed, it is possible to add suffix/suffix in other ways.
But it’s simply much faster to just push a hotkey (Alt+M in this case) and do introduce the values for the prefix and the suffix. It’s increasing the productivity a lot.Thanks for pointing to the right direction for filling feature requests.
But maybe I’ll post my suggestions here first and only after that in the issues-sf sub-forum. -
I forgot to mention a
#3for both prefixing / suffixing: You could script this behavior with one of the scripting plugins.I wish you Good Luck with your feature request.
-
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:

Step B:

Step C:

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()
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login