VS Code 如何學會並記住鍵盤快捷鍵
How to Learn VS Code Keyboard Shortcuts (and Actually Remember Them)
作者建議從日常操作中找出最常遇到的摩擦,每次只學兩個 VS Code 快捷鍵,並以快捷鍵取代重複的滑鼠操作。文中介紹 Ctrl+P 開啟快速開啟、Ctrl+D 選取目前字詞的下一個出現位置,並建議先熟悉預設按鍵。透過隔日、數日後及一至兩週後主動回想,按每週兩個的節奏練習,三個月約可熟練二十多個快捷鍵。
I used VS Code for about two years before I learned that Ctrl+D selects the next match of whatever word the cursor is on. Two years of double-clicking, renaming, double-clicking, renaming. A coworker watched me do it during a pairing session, said nothing, and then did the same edit in four keystrokes. That was enough.
So I printed the official cheat sheet (Help > Keyboard Shortcuts Reference), stuck it next to my monitor, and learned almost nothing from it. It has well over a hundred entries. After a week I was using the same five I already knew, and the sheet had turned into wallpaper.
What worked later was much slower and much smaller. Here's the approach, plus the shortcuts I'd start with.
Don't learn the list. Learn the next one.
Shortcuts stick when they replace something you already do by hand, many times a day. If you learn Ctrl+Shift+O (go to symbol in file) but you never navigate big files, it's gone by Friday.
So before memorizing anything, spend a day noticing your own friction. Every time you reach for the mouse, or scroll looking for something, or retype a line you just wrote, make a tick on a sticky note with a word for what you were doing. "find file", "move line", "rename", "terminal". At the end of the day the top two ticks are your next two shortcuts.
Two at a time. Not ten.
A starter set that pays off fast
These are the ones that changed my day the most. Windows/Linux keys shown; on a Mac, swap Ctrl for Cmd and Alt for Option in most of them.
Getting around
-
Ctrl+Popens Quick Open. Type part of a file name and hit Enter. I stopped using the file tree for almost everything. -
Ctrl+Shift+Popens the Command Palette. If you forget a shortcut, the command is in here, and it shows you the keybinding next to it. This one teaches you the others. -
Ctrl+Gjumps to a line number. Handy when a stack trace tells youline 212. -
F12goes to definition, andAlt+Lefttakes you back.
Editing
-
Alt+Up/Alt+Downmoves the current line. No more cut, scroll, paste. -
Shift+Alt+Downcopies the line below. -
Ctrl+/toggles a comment. -
Ctrl+Shift+Kdeletes the line.
Multi-cursor (the one from the pairing session)
-
Ctrl+Dadds the next occurrence of the current word to your selection. Press it again for the one after. -
Ctrl+Shift+Lselects every occurrence at once. -
Alt+Clickdrops an extra cursor wherever you click.
Refactoring and layout
-
F2renames a symbol across the project, which is safer than find-and-replace. -
Ctrl+`toggles the integrated terminal. -
Ctrl+Bhides the sidebar when you want the whole screen for code.
Don't try to take all of that in today. Pick two from whatever your sticky note said.
Make the mouse slightly annoying
Knowing a shortcut and reaching for it are different skills. The second one only comes from repetition under mild pressure.
For the week you're learning a new pair, force yourself to use them even when the mouse is right there and would be faster. If you catch yourself scrolling the file tree, stop, undo it, and hit Ctrl+P instead. It feels silly for about three days. Then your hand starts doing it before you think.
Some people go further and hide the activity bar or the tabs so they have no choice. I didn't need that, but it works for some.
Customize only after you know the defaults
Ctrl+K Ctrl+S opens the Keyboard Shortcuts editor, where you can search any command and rebind it. It's tempting to remap everything on day one. I'd wait. Default bindings show up in docs, blog posts, tutorials and your teammates' screens, so learning them first means every tip you read later just works.
The exception is if you're coming from another editor. The Keymap extensions for IntelliJ, Sublime, Vim and others exist for exactly this, and fighting years of muscle memory isn't worth it.
Then come back to them on purpose
Here's the part I got wrong the first time. I'd learn a shortcut, use it a lot for a week, then move to a different project where I didn't need it for a while. A month later it was gone.
The fix was boring: a short list of the shortcuts I was learning, which I looked at again after a day, then a few days later, then a week or two after that. Each time, I'd read the action ("select all occurrences") and try to recall the keys before looking. If I got it, it went further out. If I didn't, it came back sooner. That's spaced repetition, the same thing flashcard apps are built on, and it works on keyboard shortcuts as well as it works on vocabulary.
I build Recl, and this is the kind of thing I made it for. A lot of my shortcut learning came from short YouTube videos and blog posts with titles like "VS Code tricks I wish I knew sooner". I'd watch one, nod, and forget all of it. Now I save the video or article (the Chrome extension even has its own shortcut for this, Ctrl+Shift+S, or Cmd+Shift+S on a Mac), Recl writes a summary with the key takeaways, files it under a topic like "VS Code", and brings it back later with a recall question so I'm tested before it fades.
You don't need an app for this, though. A text file of "shortcuts I'm learning" and a reminder on your calendar does the same job. What matters is seeing them again before you forget, instead of rereading the whole cheat sheet every six months.
A realistic pace
Two new shortcuts a week sounds slow. Over three months that's about two dozen you actually use without thinking, which is more than most people ever get to. And because each one replaced a real annoyance, you'll feel every one of them.
Start with whatever you reached for the mouse to do most today. That's the next shortcut.
I build Recl, an AI learning app that saves the videos, reels and articles you learn from, summarizes them, sorts them into topics, and uses spaced repetition so you actually remember them.
來源:DEV Community · dev.to

