Space in hostring without end chars

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
asheroto
Posts: 7
Joined: 25 Apr 2019, 16:12
Contact:

Space in hostring without end chars

Post by asheroto » 29 Jan 2022, 02:52

Hello!

I want to add a hotstring so that when I press

Code: Select all

{space} i {space}
it replaces the lowercase i with a capital I.

Meaning...

Code: Select all

 i
becomes

Code: Select all

 I
I can't seem to figure it out. I have tried using ^Space without success.

What's the trick?

Thank you!

gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: Space in hostring without end chars

Post by gregster » 29 Jan 2022, 03:01

If I understand correctly, such a hotstring could look like this (assuming you want the replacement text without these spaces):

Code: Select all

:C*: i ::I
This should work at the beginning of words. If it should also work inside words, you could also add the ? option.

See also:
https://www.autohotkey.com/docs/Hotstrings.htm#remarks wrote:Spaces and tabs are treated literally within hotstring definitions.

User avatar
asheroto
Posts: 7
Joined: 25 Apr 2019, 16:12
Contact:

Re: Space in hostring without end chars

Post by asheroto » 30 Jan 2022, 12:46

gregster wrote:
29 Jan 2022, 03:01
If I understand correctly, such a hotstring could look like this (assuming you want the replacement text without these spaces):

Code: Select all

:C*: i ::I
This should work at the beginning of words. If it should also work inside words, you could also add the ? option.

See also:
https://www.autohotkey.com/docs/Hotstrings.htm#remarks wrote:Spaces and tabs are treated literally within hotstring definitions.
Thanks. Almost got it perfect. But I need it to replace as I'm typing a sentence. For example, if I type...

Code: Select all

Then i went to the store.
It should replace it to be

Code: Select all

Then I went to the store.
How can I get it to detect within a sentence?

gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: Space in hostring without end chars

Post by gregster » 30 Jan 2022, 13:12

You mean something like this?

Code: Select all

:C*?: i :: I `
this would preserve the typed spaces around the I, and would work inside a word. (You are technically still inside the last word if you just press one space, because that space is actually part of your hotstring trigger - which, by default, would be deleted by the substitution text).

Post Reply

Return to “Ask for Help (v1)”