Generate editable cursor positions on VSCode [duplicate] - visual-studio-code

In sublime text I used to use a shortcut that allowed me to tab through my multi selection and edit each element individually.
for example I would cmd+d a word then the shortcut would allow me to tab through each selection and edit them individually.
I haven't used sublime text in a month since I switched and can't even remember the shortcut I used to find the name of that action. so I don't even know if it was a plugin or a built in short cut.
is there a similar shortcut in vscode?

You can multi-select in VSCode using alt+click
(can be changed to cmd+click in "Selection -> Switch to Cmd+Click for Multi-Cursor").
To tab through your selections install the tab-through-selections extension and then use cmd+shift+u to start iterating (alternativley ctrl in Windows), then:
tab to go to the next selection
shift+tab to go to the previous selection
click anywhere to cancel iterating
Hope this helps :)

Related

Commenting out code does not work properly in VS code

I used to able to comment or uncomment multiple lines of code by pressing ctrl+/
# x = 10
# print(x)
But now I press ctrl+/, it becomes the following:
...
I tried to search for solution online, and I believe it is because the Windows shortcut somehow overwrite the shortcut in VS code. But I cannot find a solution.
I tried:
1.Reset the shortcut
2.Reinstall VS code
They don't work. Any help is appreciated.
First of all see which keyboard layout you are using on your System. Change the Keyboard layout to US-Keyboard if US keyboard is not selected.
If it is US keyboard then,
The shortcut key might have changed.
You can edit your preferences on VS code.
Goto File > Preferences > Keyboard Shortcuts
Search for Toggle Line Comments.
Click on edit icon and press your desired shortcut key
It could also be caused due to the same key bindings for shortcuts.The Keyboard Shortcuts editor has a context menu command Show Same Keybindings, which will filter the keybindings based on a keyboard shortcut to display conflicts. To view same key bindings follow the above steps till Step 3.
Now right click on the Toggle Line commands and click Show same key bindings.
It depends on what language you are programming.
But if you want to type # character you can hold down shift key and press number 3 on your keyboard.
I encounter this problem before. You should press shift key to switch back to type English and try again.

loop through multiple selections and edit individually in vscode

In sublime text I used to use a shortcut that allowed me to tab through my multi selection and edit each element individually.
for example I would cmd+d a word then the shortcut would allow me to tab through each selection and edit them individually.
I haven't used sublime text in a month since I switched and can't even remember the shortcut I used to find the name of that action. so I don't even know if it was a plugin or a built in short cut.
is there a similar shortcut in vscode?
You can multi-select in VSCode using alt+click
(can be changed to cmd+click in "Selection -> Switch to Cmd+Click for Multi-Cursor").
To tab through your selections install the tab-through-selections extension and then use cmd+shift+u to start iterating (alternativley ctrl in Windows), then:
tab to go to the next selection
shift+tab to go to the previous selection
click anywhere to cancel iterating
Hope this helps :)

Disable multi cursor functionality

I do not like the Visual Studio multi cursor options, and I never use them.
Inevitably, I phantom-pressing some key combination that brings up a multi cursor option, then I write some code, and then the code is destroyed afterward. Please tell me how to completely disable all such functionality in Visual Studio Code. I am running on Ubuntu, but also interested in how to accomplish this on Windows (if there is any difference).
I should mention, that this happens literally once every 5 minutes to me on Ubuntu, but in Windows it happens much less frequently (like once an hour).
Un-check Selection->Column Selection Mode
You can remove the keyboard shortcut(s) that trigger this functionality.
Click on the gear on the bottom-left corner of the window and choose "Keyboard Shortcuts" from the menu. Type "Add Cursor" into the "Search" box and it shows only the commands that contain "Add Cursor" in their name.
Right-click on each command that add a cursor and has a keyboard shortcut associated and select "Remove Keybinding".
Also search for "Multi-Cursor". It could return the command "Toggle Multi-Cursor Modifier" that is associated to a combination of modifier keys (one or more of Ctrl, Alt, Shift). If such a combination of keys is pressed when you click in the editor window it adds a new text cursor at the click position. You should also removed these key bindings.
Set this settings in editor settings :
"editor.columnSelection": false,
In Android Studio :
Un-check Selection->Column Selection Mode

Shortcut key to jump to "files to include" input in Find In Files

I use the keyboard shortcut for Find in Files (CtrlShift+F), and use other hotkeys, like Alt+R to toggle regex matching on/off (though I wish they'd used the same shortcuts as Visual Studio!
In Visual Studio you can jump to the File Types input with Alt+T, but I can't figure out a way to do it in VS Code, I have to resort to pressing Tab 5 times. Anyone know the keyboard shortcut to jump directly to that input?
New answer:
Up/down arrows now navigate the history of each search field. You can use cmd+up/down to switch between the inputs.
Original answer:
You can use the up/down arrows to switch between these inputs.
VSCode 1.70 (July 2022) adds a related feature:
Search Editor: Allow Keyboard Shortcut for File to Include/Exclude
In the search editor, there is search.action.focusQueryEditorWidget to focus on the query.
I'd like to be able to set a keyboard shortcut to focus on "files to include" and "files to exclude".
Fixed with PR 153954
This adds keybindings to quickly focus on files to include/exclude.
I tried to follow the pattern for the toggle X keybindings, so I went with:
Cmd+Alt+F and
Cmd+Alt+Shift+F.
I used "F" for "files".
This is available in VSCode insiders today.

Keyboard shortcut for "open next search result"?

Eclipse has this great feature of searching text in Workspace(Ctrl+Alt+G), Project, File or Working Set.
The results are displayed neatly in a Search tab/view and when I double-click (i.e. mouse) a particular line, the file (in which that searched text is found) is open exactly at where the search text is.
Is there a keyboard shortcut for that double-click? To open the next one?
There is not one keyboard shortcut to perform this action that I know of, but there are two of them that could work in sequence.
Go to Window > Prefs > Keys
Search for "Show view search"
Set some custom keyboard shortcut because the default one is too long to be efficient (I like to use Alt+Shift+S)
Perform your search
With the search view in focus double-click the first result
When you are ready to go to next item, use a keyboard shortcut to show search view again (Alt+Shift+S for me)
Then press 'Ctrl+.'
This shortcut will display the next result and open a new file is needed.
So with this sequence you can use two keyboard shortcuts (Alt+Shift+S then Ctrl+.) to do what you want.
Checkout the Eclipse Keyboard Shortcuts PDF list for v2.1, v3.0, and v3.1 HERE
#gamerson has the right answer, but for the future I wanted to make sure you are aware of two key meta keyboard shortcuts:
Ctrl-Shift-L (Command-Shift-L on Mac) - Opens up a searchable list of available shortcuts.
Ctrl-3 (Command-3 on Mac) - Quick Access gives you a searchable, prioritized list of a bunch of stuff - commands, menu items, windows, tabs, etc. It's pretty darn useful.