Text Replacement (and other text input features)

In the previous betas, the program respected system-wide text replacements specifically the ability to have a period through two spaces, and the first letter of a new sentence was capitalized. The latest version still does the two spaces turn into a period bit, but doesn’t capitalize the first letter of a new sentence anymore. Can we have that back?

macosxguru

Are you sure this was ever working in Bike?

I’m building the Bike text editor from ground up, meaning I don’t get all the free behavior from NSTextView. This makes lots of Bike’s features possible, it also means Bike lags behind in some features such as text replacement.

There’s also a bit of mystery in this approach. The underlying text input API’s that I’m making use of aren’t quite as well explored or explained as other parts of appkit. Anyway that is all to say that I think I’m getting the “two spaces inserts a period” from the text input system NSTextInputClient.

I don’t think NSTextInputClient does autocapitalization, and so I don’t think Bike has ever supported autocapitalization either. But I could be wrong and would like to know… maybe I can use NSTextInputClient to get auto capitalization.

In any case I do plan to eventually implement the full macOS text system experience, it just takes time. In this last week I have been exploring the API’s further with this example project (GitHub - jessegrosjean/NSTextInputClient), but I haven’t yet integrated any of that work into Bike.

I thought it did, but I could be wrong. My auto-shifting Planck keyboard might have confused me.

However that is a feature which I rely on and makes typing easier in native apps. Looking forward to Bike supporting that in future versions.

I’m pretty sure this has never worked in Bike, because the “add a period if you type 2 spaces” thing is part and parcel with the Text Shortcut replacements you can create in System Preferences: Keyboard: Text. Those replacements don’t work in BBEdit, either, because BBEdit uses its own written from the ground up editing environment too. And (checks notes…) BBEdit has been around for a couple of years.

It is always intimidating to contradict John Gruber, the creator of Markdown.

You are right about BBEdit not supporting these text replacement features.

I have the settings that you mention in the Keyboard>Text preference pane.

The two spaces turn into a period works. The capitalization doesn’t.

The proof is in the video.
CleanShot 2022-03-18 at 16.42.41.mp4.zip (1.2 MB)

Huh, how about that! I guess I should have tried turning on “Add period with doube-space” before saying it didn’t work! Bad assumption on my part. No reason to be intimidated — my family tells me I’m wrong all the time!

1 Like

I’d like to log a feature request for following the system settings at System Preferences → Keyboard → Text, including smart quotes, smart dashes, and text replacements.

2 Likes

Another missing text input nicety is automatic space deletion. For example, if you write “one two three” then delete ”two”, you’ll be left with 1 space between “one” and “three”, not 2. It’s not a big deal, but missing it is a speed bump when one is used to the rest of the system doing it.

The behavior is subtle, though. Consider “one two three” → “two three” (no space at the beginning), “one two three” → “one two” (no space at the end), and “one two.” → “one.” (no space before the period). It also distinguishes between selecting a word (for example by double clicking it) and selecting a range that happens to also be a word (for example by clicking and dragging), and only deletes spaces when working at the word level.

There’s also corresponding space insertion when pasting in text, again only while working at the word level. For example, with cursor position marked with “|” and clipboard content “two” without spaces: “one|.” → “one two|.”, “one|three” → “one two |three”.

Bike’s text input is a level 1.0 right now. There’s another set of interfaces that I need to implement to get to the next level. I’m going to move this request in with the other related ones.

1 Like

@jessegrosjean Minor: It would be nice if Bike honored macOS’s builtin text replacement shortcuts. I’m referring to the list of replace/with combinations in System Preferences → Keyboard → Text. I don’t use these extensively, but I have a few I use commonly enough that it came up very early in experimenting with Bike, and I was surprised to see it “not work” (the shortcut wasn’t replaced with the text defined in System Preferences).

I assume this is a consequence of writing your own text system. Offhand, I don’t even know if there’s a public API in AppKit to query those replacements/shortcuts, but if there is, it would be neat to see them work in Bike.

Working on it (and all the autoreplcement stuff) in this prototype. Early in Bike’s development I tried, but couldn’t find any implementation of NSTextCheckingClient anywhere, and not much documentation, so gave up. Iv’e made recent progress in that example, but integrating it all into Bike will take some effort.

1 Like

Moving to related post…

Could Bike allow the use of Mac native spell check and suggestions (esp. useful on TouchBar MBPs)? I tried to use it today to take notes in a meeting and when I have to type fast, I make mistakes & I rely on my Mac to fix my errors.

Planned, but still in progress. I’m moving this comment to a thread of similar comments.

Hello

I used a lot apple text replacement. It doesn’t work within the app

@Bruno_Busch Yes, it’s just a missing feature right now. I’ve moved your post into a larger discussion of this feature. I expect to add support in the medium future.

1 Like

Really liking Bike so far!

I’d also be interested in this feature if eventually get time for it. I use text replacements like :->: and :inf:, for Unicode symbols.

Totally empathize with having to reimplement macOS text features. We had similar craziness at Figma! Love the the innovation you’ve done around text editing.

1 Like

Thanks!

Good news is that since this thread I’ve got an implementation going and text replacement is available in the current preview:

Please give it a try and let me know when you see rough spots.

1 Like