I want to assign a shortcut to a macro that deletes a line, regardless of its content.
I don't want to process the whole file and remove lines based on certain criteria.
I want to be able to just move my cursor up and down and wherever my cursor is, I hit the shortcut and it deletes that line, making everything else go up.
I mean, if I can target any application that deals with text editing, that would be perfect.
I mainly use these now (by order of priority, high to low)
Obsidian
TextEdit
Pages
Notes
Obsidian is where I've been spending more time and where I see myself doing this more often, followed by TextEdit. The other two are just extras. If I can at least do it in Obsidian and eventually (not required) in TextEdit, I'm already a happy guy
This could be an option, but it doesn't work if there's text in the line
For example if you have this
Text1
Aaaaa
Text2
And you use that macro you end up with this
Text1
Text2
But I wanted to delete the whole line and get this
Text1
Text2
One way to achieve this would be to use CMD X after the right arrow action. If there's no text it will delete that line and it ignores the Delete action. So after CMD X we could check if the clipboard has any content (text, numbers, etc) and if so, run the Delete action, if not, ignore the Delete
This looks like a work around, but I was wondering if there was maybe an AppleScript or Shell script that could do this?
When the line is empty and we use CMD + X, the clipboard doesn't become empty, that's why I added the first action. So if we hit CMD + X and the clipboard remains EmptyLine, that means that the current line was already empty, because the line was automatically deleted when we hit CMD + X so it ignores the Delete keystroke.
1 - Your coordinates point to the top left corner of the window, not the line
2 - Even if we could use the triple click, the mouse would have to be exactly where the line is, which is not ideal if you are trying to delete things in series, like "delete, move on to the next line, delete, move on", etc... I want to be able to delete a line, use the arrows to move to the next line, shortcut to delete, arrow, etc
3 - Triple click doesn't always work (in Obsidian, for example, it just selects the text, not the whole line). So I would always need an IF THEN to check if there was an empty line or not.
I tried with Control K, but the end result is not the same. It just deletes the text, not the line.
It seems that different apps actually behave differently. For example Obsidian, when hitting CMD X deletes the line if it's empty. Notes, does not.
So I need to change the macro to add some conditions depending on the front app.
Yes, the CMD+X is what changes the clipboard state and allows the macro to do its thing.
I updated the macro above, because I had to make changes for Obsidian.
Thanks for sharing.
Yes, it works with all 4 apps I can think of that I use: TextEdit, Pages, Obsidian, Notes.
Even if we need an IF THEN for other apps, it's still a shorter version compared to mine.
I added a link to your reply if others want to use that instead.
⌘-LeftArrow and ⇧-DownArrow semantics are really quite common in Mac text apps (more so than the Emacs-style shortcuts like Ctrl-A, Ctrl-E, etc.). Go figure, they even work in alien programs like MS Word
In InDesign, you can easily "standardize" the text shortcuts, so you don't need a conditional for that either (unless someone really loves the Adobe shortcuts):