Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code: keybinding to move cursor to next occurrence of word under cursor

If my cursor is under word foo in text, is there a keybinding in VS Code that will move the cursor to the next occurrence of the word foo in the text?

(I had this feature in my previous IDE, IntelliJ IDEA. It was called Find Word at Caret)

like image 800
M.K. Safi Avatar asked Aug 27 '17 03:08

M.K. Safi


People also ask

How do you move the cursor to the next line in VS Code?

Mine is Visual Studio Code and the exact command for this is "Add cursors to line ends". The shortcut key is Alt + Shift + I (Windows) or Command + Shift + l (Mac).

How do you replace multiple words in VS Code?

Visual Studio Code v 1.3. Replace functionality can be accessed: In the Search View by expanding the Search textbox. Using Ctrl + Shift + H , from the Edit | Replace in Files menu. Using Replace in Files command in the Command Palette.


1 Answers

To find the word at caret, do the following:

Use Ctrl+F keyboard shortcut then press Enter.
To navigate between the occurrences of the word at caret
Press F3 to go to the next occurrence.
Press Shift+F3 to go to the previous occurrence.


Or just Press Ctrl+F3 and Ctrl+Shift+F3,

You may see/change that shortcuts in the editor by going to the menu under File > Preferences > Keyboard Shortcuts. (Code > Preferences > Keyboard Shortcuts on Mac)
then search for find selection, see:
enter image description here


See Key Bindings for Visual Studio Code, and Keyboard shortcuts cheat sheet in PDF file format for Linux , macOS, and Windows.


Multiple selections (multi-cursor)

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.
Press Ctrl+D again for Multiple selections or you may just Press F3 to go to the next occurrence. Press Shift+F3 to go to the previous occurrence.


And if you enjoy vim, you may install VSCodeVim extension, which is a Visual Studio Code extension that enables Vim keybindings, and like vim: Press * to search for the next occurrence.

like image 53
wasmup Avatar answered Sep 22 '22 21:09

wasmup