Page 1 of 2

Applying QuickFix after I've written a document

Posted: 2010-10-06 00:13:34
by julius
Hi,
I like the QuickFix funcion and I wonder if it can be applied to a document or a selection after it has been written and not only in real-time when I'm writing a document.

Thanks..

Re: Applying QuickFix after I've written a document

Posted: 2010-10-06 00:48:33
by Hamid
QuickFix works only while you are writing; it is triggered when you press the space bar after a typo or an abbreviation set down in your Glossary files. QuickFix cannot be applied subsequently to a document because the triggering element is then missing.

Re: Applying QuickFix after I've written a document

Posted: 2010-10-06 02:46:40
by Kino
julius wrote:I like the QuickFix funcion and I wonder if it can be applied to a document or a selection after it has been written and not only in real-time when I'm writing a document.
Try this macro. It so-to-say retypes selected texts using insertText command with q option (“apply the user’s QuickFix preferences to the inserted text”). If there is no selection, it creates a copy of the document and works on its whole text (main body and notes). However, it is not practical to run the macro on a large document. It is slow and requires that the target window is always active. In other words, you should not touch your Mac while it is running.

Code: Select all

$doc = Document.active
if $doc == undefined
	exit # no open document
end

$sels = $doc.textSelections
if ! $sels.firstValue.length
	$doc = $doc.copy
	$paraStarts = $doc.text.findAll '^(?=\p{Any})', 'E', '-am'
	$sels = Array.new
	foreach $start in $paraStarts
		$range = $start.text.rangeOfParagraphContentAtIndex $start.location
		$sel = TextSelection.new $start.text, $range
		$sels.appendValue $sel
	end
	if $doc.allNotes.count
		foreach $note in $doc.allNotes
			$sel = TextSelection.new $note.fullText, $note.fullTextContentRange
			$sels.appendValue $sel
		end
	end
end

$null = Cast to String "\x00"
foreach $sel in reversed $sels
	$words = $sel.subtext
	$words.replaceAll '(?<=\s)(?=\S)|(?<=[,.;:!?\'\’"”)])(?=\s)', $null, 'E'
	$words = $words.split $null
	$range = $sel.range
	$range.length = 0
	$doc.setSelection $sel
	$sel.text.deleteInRange $sel.range
	TextSelection.setActiveRange $range
	foreach $word in $words
		$doc.insertText $word, 'q'
	end
end

Re: Applying QuickFix after I've written a document

Posted: 2010-10-07 04:02:04
by julius
Hi,
Thanks both for the answers.
What I really want is to correct text that doesn't start paragraphs with uppercase caracter.
Microsoft Word has this function (change case / sentence case) and I can apply it to the text selected.
If the text in the selecion start a paragraph with a lowercase caracter the command change ìt to uppercase.

Re: Applying QuickFix after I've written a document

Posted: 2010-10-07 16:39:34
by rmark
I'm sorry you experience difficulties with Nisus Writer Pro.

You could try this two-line macro:

Code: Select all

Find All '^.', 'Ea'
To capitalized

Re: Applying QuickFix after I've written a document

Posted: 2010-10-08 00:27:43
by julius
Hi,
thanks for the macro, I tested it but it gives me an error.

Re: Applying QuickFix after I've written a document

Posted: 2010-10-08 00:44:25
by Groucho
You can also use Find and Replace with PowerFind Pro and the following settings:

Find what: ^.
Replace with: \T{uppercase:\0}

If you prefer a macro, click on the gear and select Macroize…

Cheers, Henry.

Re: Applying QuickFix after I've written a document

Posted: 2010-10-08 09:25:36
by julius
Hi,
it works like a charm.
Thanks..

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 17:13:48
by appledogx
I'm very surprised that this feature is not standard in Nisus Writer Pro. It seems like it should be a very basic menu item for an advanced word processor. I had to revert to LibreOffice to change some text I was working with.

I tried the ^. to \T{uppercase:\0} PowerFind Pro and it doesn't seem to work for me. Does it require regex? All I seem to get is the first letter of the sentence highlighted, but no changes to my text.

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 17:44:32
by martin
appledogx wrote:I tried the ^. to \T{uppercase:\0} PowerFind Pro and it doesn't seem to work for me. Does it require regex? All I seem to get is the first letter of the sentence highlighted, but no changes to my text.
Those find patterns are indeed PowerFind Pro (regex) expressions. Your find dialog should look like this:
find.png
find.png (33.81 KiB) Viewed 15833 times
You'd then click the "Replace All" button. Please let us know if you continue to have trouble.

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 20:31:36
by appledogx
I'm fairly new and not quite getting this for some reason. I have just what you posted, but this is what I get, and what I'm trying to get:

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 20:39:17
by phspaelti
What kinds of changes were you expecting to see?

The expression that Martin described is "doing" exactly what it says: It is capitalising, perhaps redundantly, the first letter of every paragraph. The highlighted letters are the ones targeted. And as you can see they are all capitalised. Of course they were probably already capitalised, but so what?

So what result are you looking for?

Anyhow for what it's worth, here is an attempt at a find expression (macroized) that will do sentence capitalisation in the current selection.
Sentence Capitalize Selection.nwm
(18.36 KiB) Downloaded 565 times

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 22:17:58
by exegete77
Just a thought, perhaps the file needs to be named and saved. I have found other features that don’t seem to stick if the document is not named.

Re: Applying QuickFix after I've written a document

Posted: 2014-01-10 22:25:24
by phspaelti
exegete77 wrote:Just a thought, perhaps the file needs to be named and saved. I have found other features that don’t seem to stick if the document is not named.
This is not relevant. The find/replace is working fine as appledogx's image shows.
It seems he was expecting the first sentence(s) of his file (all in upper case) would be converted to lowercase, and then sentence capitalisation applied. For that result, it will be necessary to do the following steps:
  1. Select the relevant text
  2. Choose Edit > Convert > To lowercase
  3. Use a find expression (or the macro I supplied earlier) to capitalise the sentence initial letters.

Re: Applying QuickFix after I've written a document

Posted: 2014-01-11 06:20:38
by appledogx
Well, using this macro you've provided (thank you), I've been able to modify it and get closer... The problem I now have is that if I select after the text, I cannot seem to type any uppercase letters and I'm not quite sure how to cure this.