Multi-Line select with Alt - visual-studio-code

How can I select multi-line with vscode?
On Visual Studio you can press left alt key and select multi-lines, but it is not working with vscode.

As of May 2017, it is possible. Read the release notes:
We have introduced a new setting, editor.multiCursorModifier, to
change the modifier key for applying multiple cursors to Cmd+Click on
macOS and Ctrl+Click on Windows and Linux. This lets users coming from
other editors such as Sublime Text or Atom continue to use the
keyboard modifier they are familiar with.
The setting can be set to:
ctrlCmd - Maps to Ctrl on Windows and Cmd on macOS.
alt - The existing default Alt.

It is not available for now, but there is a feature request on uservoice:
http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7761561-vertical-text-selection

The box-selection feature in Visual Studio (where you can highlight a part of multiple lines) isn't available in VSCode.
For features like this that you would love to see in VSCode - you can add the idea to the Code User Voice pages.

Related

Is it possible to quickly swap lines in VS Code?

I'm currently experimenting with VS Code, having used Sublime Text 3 for the last five years or so. In Sublime, I could quickly swap two lines by selecting them both and then doing Ctrl+T.
As far as I've been able to find, the only equivalent command in VS Code is Alt+↑/↓, which pushes the selected line either up or down, and would be excruciatingly slow unless the selections are very close to each other.
Is this still true as of 2019? Is this basic functionality really not possible in VS Code?
There is no built-in functionality.
You can use a combination of VS Code's multi-cursor selection and the Swap extension.
Select one line or lines
Select another line/lines while holding down Alt or CMD (for Mac)
Use the extension's swap shortcut
Via keyboard shortcut
Windows: CTRL+ALT+8
Mac: CMD+OPTION+8
Via command palette
"Swap"
You can customize the keyboard shortcut to be same as what you used in Sublime.

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.

Can Visual Studio Code `quick fix` interact with keyboard?

I am using VS Code with the excellent vscodevim extension. When I navigate to a code that has a Quick Action available I can ctrl + . to activate the drop down context menu.
Is there a way to select toggle through the list of available items using the keyboard - other then the arrows keys. As a point of information, within Visual Studio it is possible using tab, this does not work in VS Code.
Why? 'cause I love my MS ARC keyboard but I hate the rocker arrow keys.
This is a known issue for linux users using vscode with advanced shortcuts like vim extension in your case, for some reason quick fix contextual menu is unattached from vscode shortcuts which makes shortcuts not work. A really easy workaround to use with a graphical interface is HotKey.
HotKey > https://github.com/autokey/autokey for Linux and create your own shortcut.

Are there bookmarks in Visual Studio Code?

How can I set bookmarks in Visual Studio Code? I can't find any keyboard shortcuts.
Or is there anything else that I can use instead?
Yes, via extensions. Try Bookmarks extension on marketplace.visualstudio.com
Hit Ctrl+Shift+P and type the install extensions and press enter, then type Bookmark and press enter.
Next you may wish to customize what keys are used to make a bookmark and move to it. For that see this question.
You need to do this via an extension as of the version 1.8.1.
Go to View → Extensions. This will open Extensions Panel.
Type bookmark to list all related extensions.
Install
I personally like "Numbered Bookmarks" - it is pretty simple and powerful.
Go to the line you need to create a bookmark.
Click Ctrl + Shift + [some number]
Ex: Ctrl + Shift + 2
Now you can jump to this line from anywhere by pressing Ctrl + number
Ex: Ctrl + 2
Visual Studio Code currently does not support bookmarks natively. Please add this as feature request to our Git Hub issue list (https://github.com/Microsoft/vscode).
In the meantime there are some ways to navigate around the code based on your navigation history. You can Ctrl+Tab to quickly jump to previously opened files. You can also navigate within your code based on cursor positions using Goto | Back and Goto | Forward.
Both VS Code extensions can be used:
'Bookmarks'
'Numbered Bookmarks'
Personally, I'm suggesting:
Numbered Bookmarks, with 'navigate through all files' option:
ctrl + Shift + P in VS Code
In newly open field, type: Open User Settings
Paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "allowDuplicates" (allow duplicates of bookmarks),
Or, paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "replace"
NOTE
Either way, be careful with shortcuts (Ctrl+1, Ctrl+Shift+1,..) that are already assigned.
Personally, mine were in 2 conflicts, with:
VS Code shortcuts, that already exists,
Ditto clipboard (I've got paste on each call of bookmark)
The bookmarks extension mentioned in the accepted answer conflicts with toggling breakpoints via the margin.
You could do the same with breakpoints and select the debug tab on the left to see them listed. Better yet, use File, Preferences, Keyboard Shortcuts and set (Shift+)Ctrl+F9 to navigate between them, even across files:
If you are using vscodevim extension, then you can harness the power of vim keyboard moves. When you are on a line that you would like to bookmark, in normal mode, you can type:
m {a-z A-Z} for a possible 52 bookmarks within a file. Small letter alphabets are for bookmarks within a single file. Capital letters preserve their marks across files.
To navigate to a bookmark from within any file, you then need to hit ' {a-z A-Z}. I don't think these bookmarks stay across different VSCode sessions though.
More vim shortcuts here.
No extension
As an alternative you can do Ctrl + P as "Go to file" in your workspace and type:
partial name of your file and/or extension.
type # + any name of method, property, variable, class (symbol) etc.
in currently opened file navigate between symbols with #
I found it more convenient than Bookmarks extension. Of course it depends a lot on your naming conventions and how well you know your codebase.
Under the general heading of 'editors always forget to document getting out…' to toggle go to another line and press the combination ctrl+shift+'N' to erase the current bookmark do the same on marked line…

Eclipse Editor consumes AltGr+A even after disabling keyboard shortcut

I use Eclipse and a non-QWERTY keyboard. My # sign is typed through Alt GR+A. This is on Windows 7.
The Eclipse Editor won't let me type an # which is bad.
I disabled the key shortcut Alt+A, it still doesn't work.
# works in other programs and in other windows inside Eclipse (e.G. find, options etc.) but not in Editor.
As this also applies to Alt GR+P (which is my } ) a general solution as to how to figure out what key events get consumed would be nice.
The Eclipse editors use the StyledText widget. This ignores some inputs depending on the platform.
On Windows the widget ignores anything with just Alt or Ctrl or Alt+Shift or Ctrl+Shift. The code claims that Alt Gr should look like Ctrl+Alt and would get through.
On Macs Cmd and Cmd+Shift is ignored.
On Linux / Motif Ctrl and Ctrl+Shift is ignored.
There is a very old Eclipse bug 20953 which sounds like this problem, but it supposed to have been fixed long ago by the code I mentioned.