Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

A macro to remove the first space

Is it possible to write a macro for the problem explained in this discussion?

https://ask.libreoffice.org/t/can-you-auto-delete-the-space-before-an-auto-corrected-word/101757

If the following sequence is found, remove the first space.

<space>bys<space>

and keep only the second one. like this...

bys<space>

In other words, if " ed " is found, then remove the first space and join it with the earlier word. If that word is "work" then the new word will be "worked".

Answer*

Draft saved
Draft discarded
Cancel
6
  • Very close. "bys" is replaced by "byś" and a space at the beginning is removed. But the question is slightly different. The resulting word should be a valid word as per spell check! After running your macro "do bys" becomes dobyś or "test bys" becomes "testbyś" but it does not check hunspell affix or dict file. This is very important. Commented Apr 24, 2024 at 9:54
  • With the way it's written now, I don't think it's possible to run the spell check on it as well because it does the search and replace in the entire document at once. The code will need to be rewritten to iterate over each replacement, and do spell check individually. Commented Apr 25, 2024 at 10:21
  • Ok. I understand that. But I do not need to change "bys" to "byś". Just make sure that the first space before the word is removed and the second space next to word is kept. There are about 8 to 10 such words (for e.g. 'ed', 'ing', 'bys'). Commented Apr 28, 2024 at 5:12
  • This is working as expected. But can I use a single function instead of 2? gist.github.com/shantanuo/1ae004359c4aadfa67c514c0c9de9ba0 Commented Apr 28, 2024 at 5:33
  • For your case, it could be simplified to a single function. You'll have to put what you want to replace inside a list, then put the main portion inside a loop. Should be pretty simple. Commented Apr 29, 2024 at 6:54

AltStyle によって変換されたページ (->オリジナル) /