How to create a keyboard shortcut (move line up/down) within a Note's $Text?

This shortcut is common in text editors these days - is there a way to create and deploy within Tbx? It’d beat the current dance (select line, Cut, delete blank line, move cursor up/down twice, hit enter, Paste).

Thoughts? I guess a Stamp, and then assign said Stamp to keyboard shortcut?

Hi Art

Keyboard Maestro excels here. It works great with Tinderbox. I would iterate the sequence you want, then assign a keyboard shortcut.

As long as there is a menu item or keystroke, KM is happy. It can even do stamps through the Interface Control Action:

Incredibly good at automating any program. I use it all the time to customize and standardize my keystrokes within most programs.

Tom

1 Like

Great, thanks Tom!

Is your task manually sorting a text list?

apples
eggs
bacon

So you want to move “bacon” between apples and eggs?

If so, my dance would be:

  1. click to the left of bacon to select the line
  2. click anywhere in the selection and drag to the start of the destination line

I don’t see a “Move Line” command in Pages or TextEdit; do you know where I should look?

2 Likes

Thanks @eastgate :slight_smile:

I am trying to do it without moving hands from keyboard, and I tend to do it a lot when sketching out and prioritizing text blocks.

The shortcut is available on the following (and others, but am not aware of specifically) apps:

MS Word - Shift-Ctrl-Up/Down_Arrow
Visual Studio Code - Alt-Up/Down_Arrow
TaskPaper and Bike - Cmd-Ctrl-Up/Down_Arrow
SublimeText - Opt-Cmd-Up/Down_Arrow

Cheers,
Art

1 Like

This doesn’t work in Sublime Text 4152, at least not for me

Task Paper and Bike

Outliners: we support this in the outline pane with cmd-up/down arrow

Sorry; it appears they’ve changed the default to Ctrl-Cmd-Up/Down_Arrow.

Maybe I got the wrong idea of what you are trying to do but on a mac:

  • arrow up/down will move the cursor one line up or down (in TBX too)
  • CMD+left arrow will move the cursor to the start of a line (in TBX too)
  • CMD+right arrow will move the cursor to the end of a line (in TBX too)
  • if you combine any of the above with the pressed SHIFT key you select the text (in TBX too)
    This is the default behaviour of a Mac and so I can select any text without leaving the keyboard?!

@webline Art is trying to move the current line/paragraph up or down in the chain of lines/paragraphs.

It’s not in the among the NSResponder bindings, but I can see it might be useful.

An edge case to consider is if the paragraph (i.e. continuous ‘line’ of text) selected contains link anchors. If you’ve a posting with 10-15 text links you definitely don’t want such a move to result in anchors ending up with the wrong place. To this day I always move $Text with links by copy/paste/delete original rather than cut/paste. I’m sure I acquired the habit when the app was much younger and the need is less now.

But, if this is supported (I too see it as interesting) we need to remember the possibility of text links in the mix. Indeed, an instant edge case that springs to mind is if anchor runs across a paragraph (line) boundary—never say ‘never’. Does all text now within the compass of the moved anchor’s start/end become part of the anchor?

I agree that there may be scenarios where unseen linebreaks may break some data or link contiguity. By and large however, my line movements are conscious and predetermined; say when I’m re-prioritizing a list of tasks that I just jotted down in Drafts and have now sent to Tbx. I would know, as soon as I moved a line, whether it’s gone to the correct place.

Poetry is a great example, accordingly I shall take a few liberties with the work of Robert Frost:

The woods are lovely, dark and deep,
But I’ve miles to go before I sleep
And promises, I know, to keep

Between the woods and frozen lake
The darkest evening of the year.
The only other sound’s the sweep
Of easy wind and downy flake.

Whose woods these are I think I know.
His house is in the village though;
My little horse must think it queer
To stop without a farmhouse near
He gives his harness bells a shake
To ask if there is some mistake.

He will not see me stopping here
To watch his woods fill up with snow.

The passage is clearly text, and would not suit me to upward-outline. That would defeat the purpose of the poem as a body of text. This analogy applies to text chunks beyond poetry - a quick list of rough notes, and so on.

In fact, I venture that, equipped with VisualStudioCode, Mr. Frost might even have been able to complete his poem more efficiently and saved himself much keyboarding choreography.

  • Alt-Up/Down to shuffle lines
  • Cmd-L to select and extend selection of line/s
  • (Shift)-Alt-Up/Down to copy a line downward; thus concluding at

And miles to go before I sleep
And miles to go before I sleep

Unrelated, but of importance to me - my left thumb is developing some variant of tendonitis, triggered by the particular way in which i cut-copy-paste (the fold-over of index finger on thumb exacerbates the pain). After a long keyboard day editing, it gets sore, and the long-term effects are beginning to aggregate. I’ve actually devolved alternate ways to press Cmd-X/C/V, but old habits die hard.

I’m simply trying to ameliorate the inevitable degradation, and save a few keystrokes in the process :slight_smile:

2 Likes

As inelegant as it sounds. Why not create a keyboard maestro shortcut to copy and paste text from tinderbox to vs code and back. Use the same shortcut and use the conflict menu to trigger the appropriate one.

Have you tried a programmable mechanical keyboard to simplify triggering shortcuts? It is useful for hours of fiddling and not getting work done. I have been using the Moonlander keyboard. It allows for pressing keys in combination - for example pressing d and f together triggers the shortcut for default folders. You can also enable pressing longer for capitalization. This might help lessen the need for combinations that exacerbate your tendonitis.

You could also trigger command V and command C by holding the respective keys down longer. Thanks for the shortcuts of VS code.

1 Like

All good suggestions, @NiranS. I’m laptop-driven these days, working from home+studio in addition to international travel (4-6x per annum); so a custom external keyboard is more hassle than it’s worth. I had looked into the Moonlander for a future time when my travel requirements die down; it seems cool but I can’t determine from the click options and would have to try out a couple of keyboards first. But it’s on the list!

For now I’ll likely go with the KM option, as pointed out by both you and @TomD.

I’m not clear about the “trigger command-V and command-C by holding the respective keys down a little longer” part. Does that work in specific apps? Or are you referring to features within the custom keyboard?

Hi @archurhh . I should have clarified. Holding v and c longer is specific for the Moonlander.

As an aside, if you have not already done so, investigate De Quervain’s Tenosynovitis as a cause for thumb based tendon pain.

1 Like

Ha! I have, and have been doing a couple of specific massages for it. Thank you for your concern :pray:

BTW, a while back, I had similar thumb pain. I found that the space bar on my keyboard was not working properly. I was having to press extra hard to get it to work. Over time, this added extra pressure. As soon as I replaced my keyboard, the pain started to subside.

1 Like

The normal ‘Mac’ way to solve this sort of thing is to add the commands to DefaultKeybinding.dict (in ~/Library/Keybindings).

For example, I’ve added a few Emacs and Vi commands. So, opt-b is backwards word, opt-B is backwords word with select, opt-delete is delete word forward and so on. (MacOS has some of these Emacs commands built in, but the shortcuts aren’t sensible, so I remap them.)

My ‘new’ shortcuts work in all standard Mac text controls, including Tinderbox text panes, so I presume that you’ll be able to use DefaultKeybinding.dict to add the ‘move line/para up / down)’ command.

I don’t use those commands myself, but, for example, this page (KeyBindings/DefaultKeyBinding.dict at master · ttscoff/KeyBindings · GitHub) has the following extract:

// Move line up
  "^@\UF700" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
  // Move line down
  "^@\UF701" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);

so presumably, it can be done. (BTW, ^ is control, @ is cmd and \UF700/1 are the up and down arrows).

This really old page explains the basics, which still apply. Key bindings - macOS - SS64.com

HTH.

6 Likes

Amazinggg!! Thanks a million, @brookter :slight_smile:
Digging into this today :+1:

1 Like

It WORKS!! Magic :dizzy:
thankyouthankyouthankyou

2 Likes

You’re very welcome! I am really pleased it worked for you.

It’s another of those ‘built in but hidden’ features for the Mac which you can’t do without once you’ve discovered it…

For example, you can also use it for typing common symbols missing from the standard keyboard layouts. E.g. I have cmd-1 and cmd-9 for therefore (∴) and because (∵).

// Misc
   "~1" = ("insertText:", "\U2234"); 
   "~9" = ("insertText:", "\U2235");

If you want to dig deeper into this, Brett Terpstra talks about it a lot: here’s his index page: Posts Tagged “keybindings” - BrettTerpstra.com. (The server was down last night, otherwise I’d have linked to it then…)

1 Like