简体   繁体   中英

I don't understand the format selection (cmd + K cmd + F) shortcut keys in VS Code

Can someone please explain to me how the "format selection" (cmd + K cmd + F) shortcut keys - and other shortcuts that seemingly have multiple button press combinations - work in VS Code.

I tried pressing cmd + K and cmd + F simultaneously (though, cmd is listed twice so I am really pressing cmd + K + F in this case) and I have tried hitting them in order. If someone could explain what they mean here, then it would be much appreciated. I am sure it's a simple solution that I have been overlooking for all these years.

The written format for shortcut expressions use the operators '+' (plus) and ' ' (space) to define whether the expressions on each side of the operator should be pressed simultaneously, or sequentially.

  • '+' represents two keys pressed then held simultaneously, in left-to-right order.

    This is the same as typing an uppercase letter using the shift key: Shift + a -> A

  • ' ' represents concatenating the right-hand-side key combo after the left-hand-side combo.

    This is the same as typing an uppercase word using the Shift key: Shift + h Shift + i -> HI

In the second example above, note that you can either keep holding Shift , or you can release it and press it again for each letter. The same applies with VSCode shortcuts.

In the case of Format Selection ( Cmd + k Cmd + f ), Cmd should be held while first k then f are pressed. Pressing k and f together is a different shortcut entirely ( Cmd + k + f ), as is pressing f and k together ( Cmd + f + k ). Since the left-hand-side key ( Cmd ) is the same for both expressions, you don't need to release it between typing the k and f .

To get a better grasp of how keyboard shortcuts are expressed, I'd suggest opening the the VSCode Preferences for Keyboard Shortcuts either using the command palette, or using the shortcut: Cmd + k Cmd + s : (type ks while holding Cmd ).

Then activate the Record Keys mode ( Alt + K ). Now type different key sequences, and it will show you the textual representation in the search bar, along with any shortcuts that match what you typed.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM