microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.14k stars 28.83k forks source link

Missing keyboard shortcut features from Sublime Text #3776

Closed waderyan closed 5 years ago

waderyan commented 8 years ago

I created an extension to port Sublime keybindings to VS Code keybindings. I made a list of all the key bindings that were missing analogous commands in VS Code.

Here is the list roughly ordered by importance. Please let me know about more I missed in the comments. If an extension exists with the functionality I added it in the far right column.

Windows / Linux Mac Description Issue Extension
ctrl+left mouse click cmd+left mouse click Add multi cursors https://github.com/Microsoft/vscode/issues/3130 None
ctrl+; None Go to Word https://github.com/Microsoft/vscode/issues/14028 None
ctrl++ cmd++ and cmd+= Increase Font Size https://github.com/Microsoft/vscode/issues/14031 FontSize Shortcuts
ctrl+- cmd+- Decrease Font Size https://github.com/Microsoft/vscode/issues/14031 FontSize Shortcuts
ctrl+shift+m ctrl+shift+m Expand selection to brackets https://github.com/Microsoft/vscode/issues/14089 Bracket Selection
ctrl+shift+j cmd+shift+j Expand selection to indent level https://github.com/Microsoft/vscode/issues/14090 None
alt+q cmd+alt+q Break / Wrap line https://github.com/Microsoft/vscode/issues/14093 None
alt+shift+1 alt+cmd+1 Switch to single column view https://github.com/Microsoft/vscode/issues/14094 None
ctrl+y ctrl+y Repeat https://github.com/Microsoft/vscode/issues/14097 None
ctrl+shift+a cmd+shift+a Expand selection to tag https://github.com/Microsoft/vscode/issues/14098 expand-region
ctrl+shift+space cmd+shift+space Expand selection to scope https://github.com/Microsoft/vscode/issues/14099 expand-region
shift+f11 ctrl+shift+cmd+f Enter distraction free mode https://github.com/Microsoft/vscode/issues/12940 None
ctrl+space ctrl+space Select next auto complete suggestion https://github.com/Microsoft/vscode/issues/14101 None
alt+shift+w ctrl+shift+w Wrap HTML tag https://github.com/Microsoft/vscode/issues/14103 None
alt+. cmd+alt+. Close HTML tag https://github.com/Microsoft/vscode/issues/14104 Close HTML/XML tag
ctrl+k ctrl+6 cmd+k cmd+6 Fold level 6 https://github.com/Microsoft/vscode/issues/14106 None
ctrl+k ctrl+7 cmd+k cmd+7 Fold level 7 https://github.com/Microsoft/vscode/issues/14106 None
ctrl+k ctrl+8 cmd+k cmd+8 Fold level 8 https://github.com/Microsoft/vscode/issues/14106 None
ctrl+k ctrl+9 cmd+k cmd+9 Fold level 9 https://github.com/Microsoft/vscode/issues/14106 None
alt+0 cmd+0 Select open tab index 9 https://github.com/Microsoft/vscode/issues/14095 None

Additionally, here are other actions that are not bound to a keyboard shortcut:

Action Issue Extension
Drag and drop selected text https://github.com/Microsoft/vscode/issues/1046 None
Tyriar commented 8 years ago

Is super mapped to ctrl or alt? Surely they don't bind win+<num>

waderyan commented 8 years ago

super is win or cmd

Tyriar commented 8 years ago

@waderyan just looked, I don't see any super in the default keybindings on Windows. Is the above the OSX version?

waderyan commented 8 years ago

Yes. From the docs it looked like this was the case

JamesHenry commented 8 years ago

(Hopefully) new VSCode convert here! One of my most used commands in sublime is shift + cmd + l which sublimes calls 'Split into Lines' (under "Selection" menu).

It creates a new cursor for each line of a given selection. Does this functionality exist in VSCode? I cannot see it in the list of missing bindings @waderyan compiled above, but I also cannot seem to find it in VSCode.

waderyan commented 8 years ago

@JamesHenry not sure how I missed that one. Added now. I don't know of an equivalent command in VS Code.

JamesHenry commented 8 years ago

Great, thanks. Consider this my +1 :)

yisibl commented 8 years ago

@JamesHenry In vscode we can used:

cmd + i and

option + shift + i

But I'm very much like the shortcut key to Sublime Text.

JamesHenry commented 8 years ago

Ah, awesome thanks @yisibl!

Yeah, I have just made it my first ever shortcut override :D

yisibl commented 8 years ago

By the way, VS Code not support cmd + j

kabirbaidhya commented 7 years ago

It would be awesome if we have all these in vscode :+1:

Tyriar commented 7 years ago

@kabirbaidhya you can install the Sublime Keymap extension that @waderyan built right now. If you find any issues you can file them to the repo https://github.com/Microsoft/vscode-sublime-keybindings/issues

nnur commented 7 years ago

My #1 most used sublime shortcut is:

Ctrl + ⇧ + ↑ Move line/selection up Ctrl + ⇧ + ↓ Move line/selection down

Any chance of adding these to the extension?

Zarel commented 7 years ago

I wrote an implementation of Join Lines and Transpose (and some other Sublime commands) which are more faithful to how Sublime implements them:

https://marketplace.visualstudio.com/items?itemName=Zarel.sublime-commands

I generally don't think it's a big deal to copy another editor's behavior exactly, but in this case, the main difference is that Sublime's behavior is less buggy. Specifically:

If you agree that these are better, could you update the readme in https://github.com/Microsoft/vscode-sublime-keybindings and this issue to refer to those?

Zarel commented 7 years ago

Also: Would you be opposed to pull requests adding these features directly into VS Code itself? These features are presumably broadly useful enough to be built-in to Sublime, and then we wouldn't need to install extensions to get access to them.

kevinSuttle commented 7 years ago

@nnur I have been itching for the same thing. Transpose sort of does it, but not the way we're used to.

gkalpak commented 7 years ago

:+1: to @Zarel's sublime-commands. The behavior for joining lines and adding cursors to selected lines are closer to Sublime Text's.

claudio4 commented 7 years ago

Please also add the crtl + click to add a new cursor.

BTW great work with the extension!

waderyan commented 7 years ago

@claudio4 added!

To all - any thoughts on prioritizing the above table? I think join lines is high, followed by ctrl+click to add new cursor. From my experience, I really miss paste and indent. More feedback is appreciated. We have working through a couple of these on our iteration plan for this month.

rebornix commented 7 years ago

@waderyan for #9415, we already have all support.

gkalpak commented 7 years ago

FWIW, the two main Sublime features I would terribly miss are:

  1. The ability to quickly switch between projects (Project > Quick Switch Project)
  2. Magically restoring my unsaved files when switching between projects or closing/reopening windows.

(But, of course, it is are more about missing functionality than just missing shortcuts.)

denvolok commented 7 years ago

Hi, tell me please, i'm binding moving up and down on shortcuts (like alt+j, alt+k), in sublime i can moving up and down with this hotkeys when suggestion menu is open (or another menu). Can i realize it in VS ?

Tyriar commented 7 years ago

@gkalpak I recommend checking out one of the project manager extensions for that, I use Git Project Manager personally.

Hot exit is coming in the next version, see #101

waderyan commented 7 years ago

@Omen-X that is not currently supported, but I have added it to my list.

gkalpak commented 7 years ago

@Tyriar, awesome to see hot-exit making it into VSCode 👍 :dancing_men:

Git Project Manager is pretty nice actually, but I miss a more flexible "project" abstraction (mainly for multi-directory projects). Fortunately, it is on the roadmap (and I can leave without it for a while :smiley:).

#AboutToSwitch

Tyriar commented 7 years ago

:+1:, FYI @gkalpak multiple folder workspaces is tracked in https://github.com/Microsoft/vscode/issues/396

waderyan commented 7 years ago

FYI there is a PR out to add functionality here - https://github.com/Microsoft/vscode/pull/15787

thekalinga commented 7 years ago

Can a shortcut be added to toggle case along with upper and lowercase, as this makes life easier to have just one shortcut to toggle case.

Which is what IDEA follows

waderyan commented 7 years ago

@thekalinga that is in the PR mentioned above 👍

thekalinga commented 7 years ago

Hi,

I see only these two

Upper case https://github.com/Microsoft/vscode/issues/14096 Lower case https://github.com/Microsoft/vscode/issues/14096

What I was asking is to have an action that can toggle. i.e if the shortcut is ctrl+t, this toggles the current selection to uppercase by default, if you press it again, the selected text would be converted to lowercase.

This is how things are handled in IntelliJ

Can u please confirm

Thanks

waderyan commented 7 years ago

@thekalinga thanks for the clarification. Can you open a separate issue for that? This issue is specific to keyboard shortcuts in Sublime Text. Sublime Text has separate commands for upper and lower case.

thekalinga commented 7 years ago

Sure. I'll open one for that.

The reason why I added a comment here is because since upper & lower are getting implemented, it would be easy for contributors to make the change in one shot.

Thanks in anycase

waderyan commented 7 years ago

@thekalinga makes sense. Thanks for your feedback!

waderyan commented 7 years ago

Note that we closed on some of these issues for VS Code 1.8 release.

Zarel commented 7 years ago

Your join lines implementation doesn't work the same way Sublime does when text is selected, and neither does your transpose implementation. :( The join lines difference is minor, but are you open to pull requests changing Transpose?

rebornix commented 7 years ago

@Zarel we are definitely open to pull requests. The reason that you are seeing differences is

If you'd like to file pull requests, please describe what kind of behavior in your new implementation and why you think it's better or more reasonable than the original one. Thanks!

Zarel commented 7 years ago

@rebornix There still exists a Sublime Text 3 behavior VS Code doesn't mimic.

Sublime Text 3 will, if some selections aren't empty, transpose the selections, putting the contents of the first selection into the second, the second into the third, etc, and the last into the first.

For instance, if you have foo bar, and you select foo and bar and do a transpose, you will have bar foo.

The use-case is stuff like:

if (key === 'up') goUp();
if (key === 'down') goDown();

I can doubleclick on goUp, alt+doubleclick (or cmd+doubleclick in Sublime) on goDown, and then ctrl+t to get:

if (key === 'up') goDown();
if (key === 'down') goUp();

In general, being able to easily swap two variables or two literals is surprisingly useful. Without this, the swap is pretty annoying to do. Something like, double-click goUp, cmd+c, double-click goDown, left, cmd+v, shift+alt+right, cmd+c, click where goUp used to be (a much smaller click target than before), cmd+v. I'd often retype them rather than deal with that mess.

That's the behavior my plugin implements, and the behavior I'd like to pullreq.

rebornix commented 7 years ago

@Zarel basically I like the idea. I did implement the word transposing at the beginning but since it requires more consideration about multi cursor mode so I didn't rush it in. We do have API for you to detect word boundary so it would be not difficult to add this feature, but like I said, multi cursor is kind of the monster. As you have already have implemented it in your extension, it would be awesome if you can contribute to the core.

bpasero commented 7 years ago

Customize keybinding support in viewlets (see this #4557)

This is added for February via https://github.com/Microsoft/vscode/issues/4557 and https://github.com/Microsoft/vscode/issues/11517

kcdipesh commented 7 years ago

How about ctrl +shift + d for duplicating the current line?

tangmi commented 7 years ago

On Windows, Sublime Text has a very useful "keybinding" to switch editor tabs with right mouse button+scroll wheel up/down. I wonder how difficult it would be to add support for this?

Seems related to #3130, however there's no mention of pure mouse keybindings.

iagowp commented 7 years ago

I'd like to see this: Add other column(s) to selection by click & drag: Ctrl + Shift + RightMouseBtn. -> windows hotkey

RamyElkest commented 7 years ago

ctrl+shift+up/down https://www.jflh.ca/2016-07-10-move-lines-up-and-down-in-visual-studio-code

elboletaire commented 7 years ago

@RamyElkest those actually exist... they're Move Line Up and Move Line Down.

Edit: note that the issue is for "missing" keyboard shortcuts.

ssteinerx commented 7 years ago

Ctrl-K/Ctrl-Y for yank on macOS.

Ctrl-K cuts to end of line Ctrl-Y yanks it back

This is ideally separate from the normal cut&paste buffer i.e. Ctrl-K followed by Cmd-V will paste the last normally cut/copied text, not the Ctrl-K buffer which can only be retrieved by Ctrl-Y

albert-001 commented 7 years ago

shift key down + righ mouse down + dragging, this is very useful for editing multi-lines at the same time.

mgiraldo commented 6 years ago

i really like sublime's ⌘+T that shows a Go To File... dialog... you then start typing characters in then dialog and files that contain those characters get listed... like a very fuzzy autocomplete

super useful for heavily-foldered projects (rails, react)

edit: never mind! this shortcut is available in Sublime Text Pack!

cmalard commented 6 years ago

ctrl+shift+d : duplicate selection (not the whole line) extension sublime-duplicate-text (not working on VSCode 1.17.2)

elboletaire commented 6 years ago

The "duplicate selection" exists in vscode. It's called copy line down.

BTW, it copies the entire line, not only the selected text.

cmalard commented 6 years ago

This is exactly what I'm talking about : duplicate selection, not the whole line ;-)