[Solved] Autocorrect text which is part of a word

Discuss the word processor
Post Reply
TonyRolfe
Posts: 22
Joined: Wed Jun 27, 2018 8:38 am
Location: NSW South Coast

[Solved] Autocorrect text which is part of a word

Post by TonyRolfe »

I am writing documents relating to the game of contract bridge and I need to be able to insert suit symbols. I have set up !C as autocorrect to a club symbol and similar autocorrect options for the other three suits.

These work perfectly when the !C is a word on its own, but does not autocorrect when used as part of a word. !C does autocorrect but 1!C does not autocorrect. Is there an option I'm missing or do I need to set up autocorrect options for all 7 levels for all 4 suits? If the latter, is there an easy way to do this or do I have to enter them one at a time?

Actually, I need the suit symbols preceded by 1-7 and I also need 13 versions for each suit symbol followed by a text. !CA should correct to the club symbol followed by A.

Advice would be appreciated

Thanks

Tony
Last edited by TonyRolfe on Fri Apr 16, 2021 9:44 am, edited 1 time in total.
Open Office 4.1.5
Windows 10 Home
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Autocorrect problem

Post by RusselB »

Regretfully, to the best of my knowledge, your options are to create an autocorrect for each possibility or enter the number/letter preceding/following the autocorrect you already have set up with a space character in between.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
Bill
Volunteer
Posts: 8929
Joined: Sat Nov 24, 2007 6:48 am

Re: Autocorrect problem

Post by Bill »

It's possible in LibreOffice by adding a wildcard sequence before and after a word part to be replaced. In this case, you would use ".*!C.*" instead of just "!C". This should allow one character before and one character after the replacement symbol.
AOO 4.1.14 on Ubuntu MATE 22.04
TonyRolfe
Posts: 22
Joined: Wed Jun 27, 2018 8:38 am
Location: NSW South Coast

Re: Autocorrect problem

Post by TonyRolfe »

Many thanks for the prompt replies.

I think I shall have to investigate libreOffice.
Open Office 4.1.5
Windows 10 Home
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Autocorrect problem

Post by John_Ha »

Try AutoHotKey where it works.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
TonyRolfe
Posts: 22
Joined: Wed Jun 27, 2018 8:38 am
Location: NSW South Coast

Re: Autocorrect problem

Post by TonyRolfe »

I've downloaded AutoHotKey and, as you said, it works.

What would be really magic would be the ability to save the current colour, set colour to red for the diamond and heart symbols and then set the colour back. I'll have to dig around in the help file to see if it can be done.

Thanks for the hint

Tony
Open Office 4.1.5
Windows 10 Home
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Autocorrect problem

Post by John_Ha »

What would be really magic would be the ability to save the current colour, set colour to red for the diamond and heart symbols and then set the colour back.
Record a macro which sets the colour of selected text to red and another setting it to black. Place the macros on a toolbar. Highlight 6♥ and click the red macro to change it to red. [Tutorial] How to record a macro (and Regular Expressions)

Also see [Solved] Card Suit Symbol Shortcuts in OpenOffice For Bridge.

You can paste a red hearts symbol into the AutoCorrect replace field. See [Tutorial] Automatic functions in Writer - enable / disable which says
You can paste things into the boxes. For example, say you want to type %6h and get it changed to 6♥ (♥ is available by Insert > Special character ...). Type %6h in the Replace box and paste 6♥ into the With box. Every time you type %6h, it will automagically get changed to 6♥.

Note that characters are only replaced when you type a following space, tab or return. If the characters are followed by another character, they are not changed. See Help.
You could probably use a Regular Expression to find "any ♥|♦ preceded by [2-9]|A|J|Q|K" and set it all red or black as required. Record it as a macro so it is just one click to execute it.

Tools > Options > Print ..., can be used to print colours as greyscales.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
JeJe
Volunteer
Posts: 2755
Joined: Wed Mar 09, 2016 2:40 pm

Re: Autocorrect problem

Post by JeJe »


What would be really magic would be the ability to save the current colour, set colour to red for the diamond and heart symbols and then set the colour back. I'll have to dig around in the help file to see if it can be done.

The macro I posted in your other thread does that

viewtopic.php?f=20&t=102714&p=496854#p496914
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
TonyRolfe
Posts: 22
Joined: Wed Jun 27, 2018 8:38 am
Location: NSW South Coast

Re: Autocorrect problem

Post by TonyRolfe »

Yes, I have been using it with some success. However, the forums I am on use the !C technique and I wanted to be consistent. I keep typing !C in my own documents.

Thanks again for that macro, it has proven to be very helpful.

Tony
JeJe wrote:

What would be really magic would be the ability to save the current colour, set colour to red for the diamond and heart symbols and then set the colour back. I'll have to dig around in the help file to see if it can be done.

The macro I posted in your other thread does that

viewtopic.php?f=20&t=102714&p=496854#p496914
Open Office 4.1.5
Windows 10 Home
User avatar
Hagar Delest
Moderator
Posts: 32594
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Autocorrect text which is part of a word

Post by Hagar Delest »

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the *EDIT button if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
JeJe
Volunteer
Posts: 2755
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Autocorrect text which is part of a word

Post by JeJe »

this macro goes back 3 characters from the viewcursor and then looks at the following 2 characters and does a replacement so that

!CA (with the cursor/text caret immediately after the A) will become ♣A

Code: Select all

Sub SuitConvert
	vc = thiscomponent.currentcontroller.viewcursor
	tc = vc.text.createtextcursorbyrange(vc.start)
	tc.goleft(3,false)
	tc.goright(2,true)

	with tc
		Select case tc.string
		case "!C"
			.string = "♣"

		case "!S"
			.string = "♠"

		case "!H"
			.charcolor = rgb(255,0,0)
			.string = "♥"
			.collapsetoend
			.charcolor = 0

		Case "!D"
			.charcolor = rgb(255,0,0)
			.string = "♦"
			.collapsetoend
			.charcolor = 0
		end select
	end with
End Sub

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply