If the cursor is in the middle of the word, or at the end, like this: here is a wo|rd in a ilne here is a word| in a ilne
Then OPT LEFT-ARROW, SHIFT OPT RIGHT-ARROW
selects the word, and of course DELETE deletes it.
If the cursor is at the START of a word, like this: here is a |word in a ilne
Then SHIFT OPT RIGHT-ARROW selects the word.
Of course, it is easy enough to write a KM Macro using "Type a Keystroke" to automate this, if you really want to.
Also, double-click on the word selects it.
Honestly, unless you really need to do this many times a day, I don't think it is worth the effort to automate. I try not to type words that I want to delete. Just my opinion.
@nikivi, this is what I mean about not being worth the effort.
I started to write a RegEx that would check for any character that you might consider a word boundary character (more than just spaces). So it gets complicated in a hurry.
You're looking at the word. Just move the cursor if it is at the beginning of the word, or just press SHIFT OPT RIGHT-ARROW.
There are going to be many exceptions that will NOT work with your macro.
For example, characters like -[]{}* etc are NOT considered "word" characters by most systems. But you might. So if you want to delete a hyphenated word, it will fail most likely.
For example, I would consider "RIGHT-ARROW" to be one word, but the Mac OS does NOT.
Sorry, but I just don't have time right now to develop this for you.
As @peternlewis sometimes reminds me, "This is a fool's errand."
No offense meant -- it is just an expression meaning likely will not work out.
If you're lucky, one of the RegEx gurus will jump in and help.
Donāt use Copy to Named Clipboard", just use Copy. No named clipboard required (and note that Default Clipboard is a Named Clipboard, different to the System Clipboard).
Use test condition
If The clipboard is not " " (just type a space).
But honestly, I would not do this - messing around with the clipboard etc just to work in one case is unlikely to be beneficial. Just accept that the macro works only when the cursor is within* the word and use it appropriately.
It is a shame that there is no Apple API to get the current selection, but that is just something you have to accept when automating on the Mac.
@peternlewis, this is a constant source of confusion. It confused me for a long time.
I think most users interpret "Default Clipboard" as what we know as the "System Clipboard".
Use of the word "Default" is a bad choice of words.
I suggest that you rename this to something like "Default KM Named Clipboard", if, in fact, it is really necessary to have this Named Clipboard at all. Why not just eliminate it?
####For two of your three cases there is already a one-keystroke key combo:
a line with| words
ā„ā«
a line |with words
ā„ā¦
Note that you donāt have to select the word before hitting Delete.
If your keyboard does not have the Forward Delete key you can get it by typing fnā«
####The cursor-in-the-middle case requires two keystrokes:
a line wi|th words
ā„ā¢ + ā„ā«
However, this is not a big thing, since your left finger can rest on the ā„ key.
Or, you could easily write KM macro for it.
I donāt think this is a Mac-specific thing. For example in Regular Expressions a Word Character (\w) is defined as [A-Za-z0-9_], that is, the underscore is a word character, the hyphen is not.
But in many apps you can configure what are word characters and what not.
ā
Besides that, there is one especially annoying thing with word characters:
A dot by itself (= not followed by a space) is ā by system default ā not treated as word break. In many cases this can be very inconvenient:
rangeOfFourItems.firstValue www.example.com
If you double-click one element the whole line will be selected. (Except in editors which are overwriting the global behavior.)
ā
This quick macro should cover all three cases (cursor at beginning of a word, at the end, or in the middle):
(āquickā = ānot thoroughly testedā, āmay delete your dataā)
Set the timeout of the Copy action to 1s or more (just for trying). Maybe your computer is so slow that the action times out before anything was copiedā¦
Almost sounds as if the Delete action (the penultimate action of the macro) doesnāt work for you. I donāt know whether the Type Keystroke actions are keyboard-dependent. I donāt think so, but try to set up that action again on your computer. As said, it must be Option-Backspace. (Backspace = Delete to the left)
Yeah I think that was the issue. My option + delete was rebinded to something else. Still though it doesnāt seems to work.
Itās okay Tom, my implementation works great for me too. If I am in front of the word, I will just move one arrow to the right. This is a pretty useful macro for me, hope anyone else agrees with me.
I am curious do you use any of these text manipulation macros that you care to share with the world?
A pity that you give up Itās certainly a very tiny detail that prevents it from working on your computerā¦
I am curious do you use any of these text manipulation macros that you care to share with the world?
This one probably not. Simply because I like to keep things simple, and a simple ā„ā« is comfortable enough for me . I just was curious to see how it could be realized with KM.