Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set hotkey to move cursor out of quotes/parenthesis?

In Sublime I could easily set a more complex hotkey that lets me exit quotes and parenthesis by pressing Enter. It is here below:

    // Move out of single and double quotes with `Enter`
    {
        "keys": ["enter"],
        "command": "move",
        "args": {"by": "characters", "forward": true},
        "context": [
            { "key": "following_text", "operator": "regex_match", "operand": "(?:\"|').*", "match_all": true },

            { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:\"|')", "match_all": true }
        ]
    },

In VS Code, is there any way to achieve this? This in keybindings.json moves the cursor, but it is active when I don't want too. Thanks.

    { "key": "enter",    "command": "cursorRight",
                         "when": "editorTextFocus" }
like image 460
cvax Avatar asked Oct 23 '16 17:10

cvax


3 Answers

In VS Code, you can type the closing quote (i.e. if using double quotes)

{shift+'}

while you are INSIDE the quotes to have it exit outside the closing quote. This also works for parenthesis and brackets, just type the closing one (i.e. ) or ]). You can also jump straight to a new line by pressing

{ctrl+enter} 

which exits out of any brackets, parenthesis, quotes you are already in. These 2 methods here should be embedded in standard VS Code AFAIK.

like image 192
quemeister Avatar answered Sep 19 '22 12:09

quemeister


Check out this extension which does what you want - https://marketplace.visualstudio.com/items?itemName=albert.TabOut

And you can find the implementation here - https://github.com/albertromkes/tabout

like image 13
Rob Lourens Avatar answered Nov 20 '22 22:11

Rob Lourens


I found Ctrl+Shift+\ useful for moving out of quotes. Also, it could be remapped by searching jumpToBracket in Keyboard Shortcuts.

See full VSCode keyboard binding here.

like image 2
eerFun Avatar answered Nov 20 '22 21:11

eerFun