Page 1 of 1

Rectangular selection and edit

Posted: 2011-10-02 15:52:40
by flips
Hi!
I just found the option to do rectangular selections (option+mouse), and I was thrilled, as I need to replace some text on many lines.
And I've been using the similar option in TextMate while programming.
There it's really simple: Select the text, press option to make it rectangular (without touching the mouse) and then delete, insert text or do whatever.

In Nisus Writer Pro (2.x) however, I was able to delete/cut the rectangle, but inserting/typing only happened on the first/current line.
Is this intentional? Is there a way to edit multiple lines in rectangular mode, like you can in TextMate?
(Would be great if it was. TextMate is great for coding and plaintext, but not an option when working together with "normal" users, who uses Word and Pages.)

Re: Rectangular selection and edit

Posted: 2011-10-02 19:31:37
by phspaelti
The classic Nisus used to be able to do this. But NWP can't … (yet… I hope).

Re: Rectangular selection and edit

Posted: 2011-10-03 13:22:52
by martin
flips wrote:Is this intentional? Is there a way to edit multiple lines in rectangular mode, like you can in TextMate?
I believe it's intentional, though also has some historical/technical reasons behind it (notably that there can be only one "insertion point"). Likely this will stay as it is, and one will not be able to type over a multipart selection. However, I do notice that one cannot paste over a multipart selection, which is unfortunate and is something that is not intentional. You should be able to paste over a multipart selection; I'll file that as an issue.

That said, here's a macro that will ask you what to replace all selections with:

Code: Select all

# get selections to modify
$doc = Document.active
If ! $doc
	Exit
End
$selections = $doc.textSelections

# ask user what to replace with
$count = $selections.count
$replacement = Prompt Input "Replace all $count selections with what text?", '', 'Replace'

# make replacements, go backwards so offsets don't shift
ForEach $selection in reversed $selections
	$selection.text.replaceInRange($selection.range, $replacement)
End