How to move text up/down in Notes using keyboard shortcut?
I want to move text up/down in Notes via the keyboard. I know it is possible in xcode with ⌘ + ⌥ + [ or ⌘ + ⌥ + ]. But it doesn't work in Notes. Any ideas?
Solution 1:
This should be possible using Cocoa bindings - see this answer:
https://superuser.com/a/283948/659069
--
The example below (taken from the link above) binds a 'move line down' shortcut to Opt-DownArrow - you should be able to modify this to meet your needs.
Create the file ~/Library/Keybindings/DefaultKeyBinding.dict and enter the following:
{
"~\UF701" = (
"moveToBeginningOfLine:",
"deleteToEndOfLine:",
"deleteForward:",
"moveDown:",
"yank:",
"insertNewline:",
"moveUp:"
);
}
This will add the shortcut Opt-DownArrow for a line-swap command (with the line below) to every application supporting the Cocoa text system.
Solution 2:
Building on David P.'s answer and a little Google-fu, I have come up with the following. I've included the explanatory comments because I found them very helpful.
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
Here is a rough cheatsheet for syntax.
Key Modifiers
^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad
Non-Printable Key Codes
Standard
Up Arrow: \UF700 Backspace: \U0008 F1: \UF704
Down Arrow: \UF701 Tab: \U0009 F2: \UF705
Left Arrow: \UF702 Escape: \U001B F3: \UF706
Right Arrow: \UF703 Enter: \U000A ...
Insert: \UF727 Page Up: \UF72C
Delete: \UF728 Page Down: \UF72D
Home: \UF729 Print Screen: \UF72E
End: \UF72B Scroll Lock: \UF72F
Break: \UF732 Pause: \UF730
SysReq: \UF731 Menu: \UF735
Help: \UF746
OS X
delete: \U007F
For a good reference see http://osxnotes.net/keybindings.html.
NOTE: typically the Windows 'Insert' key is mapped to what Macs call 'Help'.
Regular Mac keyboards don't even have the Insert key, but provide 'Fn' instead,
which is completely different.
*/
{
"~\UF700" = (
"moveToBeginningOfLine:",
"deleteToEndOfLine:",
"deleteForward:",
"moveUp:",
"yank:",
"insertNewline:",
"moveUp:"
);
"~\UF701" = (
"moveToBeginningOfLine:",
"deleteToEndOfLine:",
"deleteForward:",
"moveDown:",
"yank:",
"insertNewline:",
"moveUp:"
);
}
The behaviour mimics that of Visual Studio Code's Option-Up and Option-Down keybindings, which move the line up or down respectively and have the cursor follow the line. (Note that the cursor jumps to the beginning of the line, however)
Solution 3:
CMD + CTRL and up or down arrows works in BigSur.