microsoft/vscode

Missing keyboard shortcut features from Sublime Text

waderyan opened this issue ยท 66 comments

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 #3130 None
ctrl+; None Go to Word #14028 None
ctrl++ cmd++ and cmd+= Increase Font Size #14031 FontSize Shortcuts
ctrl+- cmd+- Decrease Font Size #14031 FontSize Shortcuts
ctrl+shift+m ctrl+shift+m Expand selection to brackets #14089 Bracket Selection
ctrl+shift+j cmd+shift+j Expand selection to indent level #14090 None
alt+q cmd+alt+q Break / Wrap line #14093 None
alt+shift+1 alt+cmd+1 Switch to single column view #14094 None
ctrl+y ctrl+y Repeat #14097 None
ctrl+shift+a cmd+shift+a Expand selection to tag #14098 expand-region
ctrl+shift+space cmd+shift+space Expand selection to scope #14099 expand-region
shift+f11 ctrl+shift+cmd+f Enter distraction free mode #12940 None
ctrl+space ctrl+space Select next auto complete suggestion #14101 None
alt+shift+w ctrl+shift+w Wrap HTML tag #14103 None
alt+. cmd+alt+. Close HTML tag #14104 Close HTML/XML tag
ctrl+k ctrl+6 cmd+k cmd+6 Fold level 6 #14106 None
ctrl+k ctrl+7 cmd+k cmd+7 Fold level 7 #14106 None
ctrl+k ctrl+8 cmd+k cmd+8 Fold level 8 #14106 None
ctrl+k ctrl+9 cmd+k cmd+9 Fold level 9 #14106 None
alt+0 cmd+0 Select open tab index 9 #14095 None

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

Action Issue Extension
Drag and drop selected text #1046 None
  • Customize keybinding support in menus (see this comment #3776 (comment))
  • Customize keybinding support in viewlets (see this #4557)

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

super is win or cmd

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

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

(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.

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

Great, thanks. Consider this my +1 :)

@JamesHenry In vscode we can used:

cmd + i and

option + shift + i

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

Ah, awesome thanks @yisibl!

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

By the way, VS Code not support cmd + j

It would be awesome if we have all these in vscode ๐Ÿ‘

@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

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

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:

  • transpose crashes when some selections are empty and others aren't; sublime-commands transposes them as expected
  • transpose behaves weirdly when there are three or more selections; sublime-commands transposes them like Sublime Text
  • join-lines crashes when a cursor is on the last line, sublime-commands doesn't
  • join-lines doesn't join the last line of a multiline selection, sublime-commands does (matching Sublime Text's behavior)

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

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.

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

๐Ÿ‘ to @Zarel's sublime-commands. The behavior for joining lines and adding cursors to selected lines are closer to Sublime Text's.

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

BTW great work with the extension!

@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.

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

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

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 ?

@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

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

@Tyriar, awesome to see hot-exit making it into VSCode ๐Ÿ‘ ๐Ÿ‘ฏโ€โ™‚๏ธ

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 ๐Ÿ˜ƒ).

#AboutToSwitch

๐Ÿ‘, FYI @gkalpak multiple folder workspaces is tracked in #396

FYI there is a PR out to add functionality here - #15787

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

@thekalinga that is in the PR mentioned above ๐Ÿ‘

Hi,

I see only these two

Upper case #14096
Lower case #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

@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.

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

@thekalinga makes sense. Thanks for your feedback!

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

  • Join lines
  • Transpose
  • Upper/Lower case
  • Paste and format
Zarel commented

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?

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

  • Vim, Sublime Text and Atom all have Join Lines, they are not totally the same when dealing with leading/trailing spaces. If you see any other difference, feel free to change it or file an issue.
  • Sublime Text 3 and 2 are doing Transpose differently. Here we mimic Sublime Text 3.

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

@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.

@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.

Customize keybinding support in viewlets (see this #4557)

This is added for February via #4557 and #11517

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

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.

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

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

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

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

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

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!

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

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

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

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

djdeo commented

sublime uses ctrl+shift+; to delete html tags (both open tag and close tag), what's the shortcut in vscode?

Is there a good way to replicate ST's layouts and their keyboard shortcuts in VSCode, even if it means using another plugin? (screenshot below of the options)

screenshot of st layouts

I can sorta use the split editor keyboard shortcut to constant split editors and go from 1 column to many, and I can use another keyboard shortcut to swap orientation, but there doesn't appear to be any way to create a shortcut like ST's cmd+alt+1 which would merge them all into a single column, which I use quite often.

jaegz commented

One of my all time favorite sublime shortcuts which I greatly miss in VS Code...

Select all inside tags / Expand selection outwards
ctrl+, or ctrl+shift+a

What about to ctrl+up and ctrl+down (arrows) to increment / decrement selected numbers? How to achieve it?

Just got it: https://marketplace.visualstudio.com/items?itemName=nmsmith89.incrementor (it's necessary to set the keybindings provided in the page and reload).

@giovannipds that is an emmet function, and it's already on vscode. No need for additional plugins.

imatge

@elboletaire right, thank you! I must haven't noticed. But the plugin does some additional stuff like swapping true and false etc., which is also cool. Will let it installed anyway. =D

tino commented

I'm missing these!

{ "keys": ["super+e"], "command": "slurp_find_string" },
{ "keys": ["super+shift+e"], "command": "slurp_replace_string" },

Is there a way to quickly switch between Workspaces just like SublimeText does with Projects? That's pretty needed... =(

Update: it kinda exists. The most similar way I've found is using Ctrl/Cmd + Shift + P then using File: Open Recent. If your workspaces are there, you can quickly change it there. File > Open Workspace... behaves similar to projects on SublimeText. Another quick tip is having all *.code-workspace files on the same dir so you can use File > Open Workspace... easily.

I'm missing these!

{ "keys": ["super+e"], "command": "slurp_find_string" },
{ "keys": ["super+shift+e"], "command": "slurp_replace_string" },

super key, on VSCode is win (I'm using win10).
For instance, I did this code on keybinding.json:

{
        "key": "shift+win+l",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "javascript",
            "name": "Print to console"
        }
    }

I hope this help someone.

I would like to add "cut from current position to the end of the line". The ctrl + k from Emacs or bash is very handy and I miss a lot this feature.

andig commented

You mean Cmd-Shift-Right Del?

You mean Cmd-Shift-Right Del?

I mean the possibility to assign that action to a simple shortcut like ctrl + k

andig commented

See #25075

*FIXED
in case anyone else needs to make this adjustment. It's SUPER simple.

File-Scroll down to Editor:Multi Cursor Modifier-select ctrlCmd BOOM..you're done.

multi cursor select is NOT working. Before I wiped the drives and installed OS in both my machines, the Sublime extension, the ONE thing I want and use the most is no longer working. A month ago, it worked. Now, not on either. I went over the posts above. I am obviously missing something. I'm running Mint 19 Tessa on both machines.

Any thoughts here? I LOVE VSC but without the multi cursor I'm back to Sublime. It's just not the same :(

mjbvz commented

Closing this aggregate issue as it is out of date

If you have any commands that you would find useful and that are still not supported by VS Code (or added by an existing marketplace extension) please open a new issue