skip to Main Content

For example, I want to move the cursor to before x but after the space before x(like the default behavior of JetBrains IDEs). When I use Ctrl+a in macOS, it move to the left of first space.

fn main() {
    // TODO: Add the missing keyword.
    x = 5;

    println!("x has the value {x}");
}

2

Answers


    • Windows/Linux: Ctrl + [left arrow]
    • On Mac: Cmd + [left arrow]
    Login or Signup to reply.
  1. As I guess, VS Code does not support that functionality directly. But we can config that feature in keybindings.json.

    Then, you may opend the keybindings.json file locates on /Code/User/keybindings.json on macOS, and add custom script

    {
        "key": "cmd+l",
        "command": "cursorMove",
        "args": {
            "to": "wrappedLineFirstNonWhitespaceCharacter"
        },
        "when": "editorTextFocus"
    }
    

    to the end of the file.

    According to this you can press CMD + L to move the cursor to the first non-whitespace character of a line. And, also you can customize the script with cursorMove command using args. You can browse args here VS Code keybindings docs.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search