loop through multiple selections and edit individually in vscode - 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

Generate editable cursor positions on VSCode [duplicate]

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 :)

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.

Can I see, and individually disable, keyboard shortcuts for extensions, such as the Sublime Text Keymap extension?

When I started using VS Code, I installed the "Sublime Text Keymap and Settings Importer" extension, to make it act more like Sublime, because that is what I was familiar with.
Now, I would like to use the default shortcuts. I want to switch gradually, maybe by disabling a few Sublime shortcuts at a time, or by at least knowing which shortcuts are coming from the Sublime extension, so I can train myself to stop using them.
Is there any easy way to see which shortcuts are coming from the Sublime extension, and ideally disable some, but not all, of them?
If I look at the "Keyboard Shortcuts" list, it shows the default shortcuts and the Sublime shortcuts mixed together, with no hint as to which is which, as far as I can tell. Example:
It shows both Command+P and Command+T as shortcuts for workbench.action.quickOpen, both with a source of "Default". But I know that Command+T is coming from the extension, because if I disable the extension, I don't see it (but I still see Command+P). Disabling the extension and restarting VS Code is kind of inconvenient, so I would like an easy way to see which shortcuts are coming from the extension.
You can see a comprehensive list of all keybindings the extension includes in the "Contributions" tab of the extension itself:
I'm not aware of any options to display this in the keyboard shortcuts UI directly. However, you could put the two tabs side-by-side for easy comparison:
Here is an updated and better method to filter the Keyboard Shortcuts editor to show which keybindings are contributed by a specific extension. See Specify which extension provides a specific keyboard shortcut. And here is an example where I search for one of my extensions, Toggle Line Comments to see if it contributes any keybindings.
And then it would be easy to disable or re-bind any of those keybindings.
Also you can click on the Extension gear icon in the Extensions list. That will bring up a menu with an Extension Keyboard Shortcuts option. Which will open the Keyboard Shortcuts editor with a search already completed for any keybindings contributed by that extension.
Keep an eye on this PR https://github.com/microsoft/vscode/pull/95713 (Show keybinding source in GUI). Looks like it may be included in vscode v1.45. It would allow you to filter the "Keyboard Shortcuts" by user-defined or extension. From the above link:
Filters examples:
#user - shows user defined keybindings
#default - shows default keybindings
#extensions - shows all extension contributed keybindings
#extensions:"${EXTENSION_NAME}" - shows keybindings contributed by
${EXTENSION_NAME}
#extensions:${EXTENSION_NAME} - same as above only without quotes
(spaces are invalid for this one)
Searching with filter and text also works:
#extensions:bookmarks list - shows keybindings from bookmarks
extension that contain the word "list"
And then with such a filtered list it would be easy to disable whichever commands you wished.

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.