4

I know it is possible in xcode with + + [ or + + ]. But it doesn't work in Notes. Any ideas?

  • 1
    What is wrong with the ↑↓ keys? – Milliways Feb 1 '15 at 1:24
  • I dont neet to move cursor, but line with text – Bartłomiej Semańczyk Feb 1 '15 at 8:24
  • You have to cut and paste. The is no option on notes to do it. Your shortcuts indent and deindent on notes.app. – jherran Feb 1 '15 at 10:36
3

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.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • Answers on Ask Different need to be more than just a link. We expect answers to be self contained, since if your link goes down, your answer will be useless. Paraphrasing the source and including any relevant information in the answer will ensure it stays relevant – nohillside Aug 2 at 12:23
  • 1
    Super User is a Stack Exchange (internal) site, but I'll copy & paste the answer if needed. – David P. Aug 2 at 13:54
  • Jumping off-site makes for a bad user experience, also answers should ideally address/solve the problem described in the question. – nohillside Aug 2 at 13:56
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)

-2

I think there is no shortcut for that in Mac. And it should have this function.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .