Eclipse的Ctrl+K快捷键在VS Code中的等效操作及PHP函数跳转方法
Hey there! Since you're transitioning from Eclipse to VS Code for PHP projects, let's tackle your two key questions:
1. Equivalent of Eclipse's Ctrl+K/Ctrl+Shift+K for Jumping to Same Words
VS Code does have built-in commands for this, though the default shortcuts differ from Eclipse:
- To jump to the next occurrence of the currently selected word: Use
F3(this matches Eclipse's Ctrl+K behavior) - To jump to the previous occurrence: Use
Shift+F3(matches Eclipse's Ctrl+Shift+K)
If you’d rather stick with Eclipse’s original keybindings, you can customize them easily:
- Open the Keyboard Shortcuts panel with
Ctrl+K Ctrl+S(or go to File > Preferences > Keyboard Shortcuts) - Search for "Find Next" – this is the command Eclipse’s Ctrl+K triggers
- Click the pencil icon next to the command, press
Ctrl+K, and save the new shortcut - Repeat for "Find Previous", setting it to
Ctrl+Shift+K
2. Jumping to Function Definitions in VS Code
VS Code supports this behavior just like Eclipse, but you’ll need the right PHP language support extension (your PHP formatter only handles code formatting, not code navigation):
Step 1: Install a PHP Language Extension
Grab one of these popular extensions to enable PHP code intelligence:
- PHP Intelephense: A robust, feature-rich extension that provides excellent code navigation, autocompletion, and definition lookup
- PHP IntelliSense (Felix Becker): A widely used extension with reliable basic code navigation features
Step 2: Use the Navigation Features
Once the extension is installed and active:
- Hold Ctrl and click the function name: This works exactly like Eclipse – it jumps straight to the function’s definition
- Use the
F12shortcut: With your cursor on the function name, pressF12to jump to its definition - Hover and click: Hover over the function name, and a popup will show the definition’s file path – click the path to jump there (just like Sublime)
Make sure you’ve opened your PHP project’s root folder in VS Code so the extension can index all your files and provide accurate navigation.
内容的提问来源于stack exchange,提问作者Red Bottle

