Rectangular selection and edit

Everything related to our flagship word processor.
Post Reply
User avatar
flips
Posts: 37
Joined: 2010-01-22 17:04:33

Rectangular selection and edit

Post 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.)
flips :)
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Rectangular selection and edit

Post by phspaelti »

The classic Nisus used to be able to do this. But NWP can't … (yet… I hope).
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Rectangular selection and edit

Post 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
Post Reply