microsoft / vscode

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

Vim Style Key binding #3600

Closed waderyan closed 7 years ago

waderyan commented 8 years ago

There are a few extensions in the marketplace for Vim, however Vim key bindings is still such a hot request in User Voice. Can VS Code / Vim users chime in on what is currently missing?

Beatusvir commented 8 years ago

@elgrego I believe having surround functionality shouldn't be an issue, it could be something like just a new command on a visual selection.

@aioutecism I'll do my best to help! specially since one of my most used commands (ciX) is not implemented yet. I'll check your code asap (currently at work). Good job man :+1:

elgrego commented 8 years ago

@Beatusvir Yeah, like vat + '

' should create a div around the current selection. Even better would be to have emmet style commands with the current selection so that vat + div|span c+y, would create a div around this and then a span after.

TrailHacker commented 8 years ago

:+1: for @elgrego's suggestion on supporting pathogen. This kind of falls into the original suggestion from @giggio to support existing ~/.vimrc files. In doing this, you could delegate the surround functionality to other community built vim plugins like https://github.com/tpope/vim-surround

websurfshop commented 8 years ago

@aioutecism This one is actually usable with .12, way to go man!

cchamberlain commented 8 years ago

Macros (q) and Multiline editing (vj>) are needed. Neovim integration would be awesome.

codeblooded commented 8 years ago

My big 4 (before anything else imo):

  • [ ] open
  • [ ] wq
  • [ ] yyp
  • [ ] line number command support like :2,10dd
74th commented 8 years ago

VSCode new vim support is very powerful. I get to make the most of function I want. Very thank @alexandrudima .

I make repeat command(.) for my vim plugin (74th/vscode-vim). Complex command, repeat command and visual mode are available. I'm looking forward to next vscode release.

arcseldon commented 8 years ago

With all due respect to the existing VSC Vim extensions, none of them provides anything close to the sort of quality support provided by say JetBrains for their range of (IDE) Editors.

For an example of what is required to be built by Microsoft (yes, you, please stop stalling with comments like we are actively evaluating but checking what is missing in Open Source - nothing has changed from a year ago when I last voted on user voice) - see ideavim - this includes all the usual keybindings, visual / command modes, and Macros support etc.

Please just get started, and stop stalling for time - this is the feature that will attract thousands of *nix / Mac devs to this otherwise awesome Editor. Would add integrated terminal support and tabs are the other two features very much needed.

hastebrot commented 8 years ago

An extension on par with ideavim is definately what is needed. Existing VS Code extensions are nowhere near ideavim. Microsoft should really pick this up and make this Vim extension.

One thing I wanted to add: ideavim uses a simple parser for .vimrc. Works good. To have something like that would also attract more Vim users.

Ah, and tabs, tabs are even in Vim considered bad. Vim users seem to prefer buffers and windows (as layout mechanism) over tabs.

johnnadratowski commented 8 years ago

👍 - really love the lightweight, snappy implementation of VSCode. If it had similar support to IdeaVim I would most likely be an overnight convert.

TrailHacker commented 8 years ago

:+1: I too would be a quick convert and spend more time developing in VSCode with better Vim support. I currently use VS2015 (with ViEmu), gVim, and/or WebStorm (ie. with IdeaVim), depending on the project I'm working on.

cchamberlain commented 8 years ago

:+1: To date, the VIM extensions are very buggy for me (right now mine never paints a cursor among other issues). This needs to be implemented in the core product.

elgrego commented 8 years ago

@waderyan, back to the original question: There are many things I use on a daily basis that are not in the current extensions. YY, yank a line, diw, delete inner word, visual selections, ciw ci", change inner. After going through a couple of the standard commands one realise that the question is a bit strange. There are hardly anything but the most basic movements in the current extension so the answer would be everything

aioutecism commented 8 years ago

@elgrego Have you tried amVim? We have yy, di", ci", visual mode, visual line mode and many other commonly used commands implemented. I use it every day, and I'm keeping adding commands people asked frequently. Contribution are welcomed too.

cchamberlain commented 8 years ago

@aioutecism is it on par with VsVim, IdeaVim, ST3 Vintageous? Are there any limitations to the plugin API that would keep it from supporting (or slow down) core vim functionality (cursor configuration, macros, regex search, : commands, etc.). Does it parse .vimrc?

If it doesn't, ST3 is a superior editor for me.

elgrego commented 8 years ago

@aioutecism this was much better, I stil miss ciw, diw, daw, dd, ct[char](the first couple of ones i tried)

aioutecism commented 8 years ago

@elgrego Thanks! dd and ct{char} should work. "Word text object(ciw, caw, diw, daw)" support will be added soon.

aioutecism commented 8 years ago

@cchamberlain Not now. However, besides : commands, most used vim commands are on the road map. We have a good code base, so it's only a matter of time to implement them.

cchamberlain commented 8 years ago

@aioutecism - I installed it. This is definitely much better than the other VIM extensions, great job!

Would still like the core product team to get involved so we can get things like / using regex instead of the built-in search tool as well as the rest of the common VIM features that are expected out of a text editor.

Platzer commented 8 years ago

Here is one of the best Atom vim plugins https://github.com/t9md/atom-vim-mode-plus

Lindenk commented 8 years ago

Ideally, I would like to see VSCode keybindings to have the option to be context based and allow key-chords and key-chains. If these keybinding options are built in to VSCode keybinding support, most vim support could be configured into using only keybindings themselves.

For example, something like:

[
    {
        "key": "l",
        "command": "cursorRight",
        "when": "editorTextFocus && normalMode"
    },
    {
        // press and release 'd', then press and release 'd'
        "key": "dd", 
        "command": "editor.action.deleteLines",
        "when": "editorTextFocus && normalMode"
    },
    {
        // press and release the chord 'ctrl+a', then press and release 'ctrl+d'
        "key": "ctrl+a; ctrl+d", 
        "command": "editor.action.deleteLines",
        "when": "editorTextFocus && insertMode"
    }
]

I know this doesn't cover all of the bases but it would certainly help to be built into VSCode itself.

If amount of fancyness is no issue, supporting regex based mappings too would be amazing:

[
    {
        "regex_key": "([0-9]+); d",
        "command": "editor.action.delete(\1)",
        "when": "editorTextFocus && normalMode"
    }
]
aakashsigdel commented 8 years ago

Please implement this in the core, the extensions out there are not very useable.

elgrego commented 8 years ago

Sometimes now and then I check in on this issue with the hope of, like a christmas present, a Vim plugin that does everything the excellent vsvim does for visual studio. Any progress?

hastebrot commented 8 years ago

@elgrego It's already there! Quite usable.

https://github.com/VSCodeVim/Vim/

Merry Christmas!

elgrego commented 8 years ago

Wow, thank you Santa 🎅!

johnfn commented 8 years ago

🎅

giggio commented 8 years ago

If we consider VsVim (for Visual Studio) a baseline, all extensions are very much behind. They are usable, but an experienced Vim user gets pissed off very frequently with the missing features.

jaredpar commented 8 years ago

@giggio people wrote the same about VsVim when it first came out (comparing to ViEmu at the time). 😄

It's basically impossible to have a vi emulator that makes 90% of the users happy on the initial release because there is no 90% use case for vi. The set of commands, modes, mappings and incredibly easy customizations mean that almost every user has a different core use case for vi. It means making 90% of the users happy is equivalent to implementing 90% of vi (tough).

I've been a vim user for almost all of my programming life. Even so during the first two years of VsVim virtually every bug report I saw was a feature I'd never heard of or new way to use a feature that I'd never encountered before. It was pretty daunting.

VsCodeVim seems to be taking the right approach here though: just keep implementing features. Every time I get an update it seems to have fixed the most recent annoyance I was experiencing. It was certainly hard to use in the initial releases but lately it's gotten much better. I rather enjoy using it now.

giggio commented 8 years ago

I agree the extensions are getting better. I hope it gets there fast! ;)

johnfn commented 8 years ago

Thanks @jaredpar!

@giggio, as a developer of VSCodeVim, please make issue requests over on http://github.com/VSCodeVim/Vim rather than just getting pissed off! We're happy to help.

rebornix commented 8 years ago

@giggio and anyone might be interested: I happen to be a developer of both VS Code and VSCodeVim. Feel free to file feature requests or issues on vscodevim, let's see what we can do to make it better from both sides (Code and extension), together.

thanks @jaredpar you just made my day.

monkoose commented 7 years ago

In vscodevim i still miss surround-plugin for vim and possibility to control all sidebar tools properly with the homerow(or may be i miss something how to do it)(or atleast some plugin compareble to advanced create file in Atom so i can work without the mouse most of my time), and i_CTRL-W that deletes all tabs and a "word" on previous line. It needs just delete all tabs first. Other than that it is already have a lot of features, even good ex mode. Thanks for your work guys.

mswift42 commented 7 years ago

I just tried vscodevim, but alas, no support for tags (which is marked as low priority).

For me this is unfortunately essential, not only to navigate through my code, but often Source Code is the best documentation.

rebornix commented 7 years ago

@monkoose @mswift42 feel free to file issues and add reactions to existing one in https://github.com/VSCodeVim/Vim :) We do have a lot of passionate contributors there and they are willing to help, just lack of feedback sometimes :)

johnfn commented 7 years ago

@mswift42, the reason that tags are low priority is because VSCode already has excellent support for tags. Try cmd-t or ctrl-shift-t. If that's not good enough, you should let us know what specifically is lacking.

mswift42 commented 7 years ago

@johnfn On my box pressing ctrl-shift-t does nothing. (This is using Linux). The working Key Combo here is F12, which is far far away from my Homerow. Also, how do I get back ? Under Vim, or Editors with good Vim Support, I'd use Ctrl+] to go to definition and Ctrl+O to get back where I was.

monkoose commented 7 years ago

@mswift42 You just need to learn more about how to rebind keys in vscode. And then just rebind showallsymbols command to a map that you want. Because by default vscodevim override ctrl-T behaviour.

mswift42 commented 7 years ago

@monkoose Thanks for that. Of course I'm not interested in showallsymbols, but in navigating quickly between methods / files.

monkoose commented 7 years ago

@mswift42 You can rebind Go To Definition command then. Its easy to do in vscode. Add this to your keybindings.json

{ "key": "ctrl+]",                   "command": "editor.action.goToDeclaration",
                                     "when": "editorHasDefinitionProvider && editorTextFocus && vim.mode != 'Insert'"},
hastebrot commented 7 years ago

@monkoose Isn't Go To Definition in VsCodeVim already bound to the gd command?

mswift42 commented 7 years ago

@monkoose: And now we are nearly half way there. I press Ctrl+] and am transported to its Definition. But how do I get back ?

monkoose commented 7 years ago

@hastebrot Yes, seems so forget about it. Thanks.

@mswift42 I do not use vscode so much(really miss surround plugin). I think the guys behind vscodevim still do not implement cursor jumps with CTRL-i and CTRL-o. Just checking it sometimes to see how far they go.

hastebrot commented 7 years ago

@mswift42 If we're still speaking about vim/VsCodeVim this should be ctrl+o (previous location) and ctrl+i (next location).

monkoose commented 7 years ago

@hastebrot Do not work for me.

hastebrot commented 7 years ago

I think the guys vehind vscodevim still do not implement cursor jumps with CTRL-i and CTRL-o

Tested it with vim.useCtrlKeys enabled. Indeed this is not implemeted.

mswift42 commented 7 years ago

That's what I was trying to say. To support jumping between tags, gotoDefinition has to save the current Cursor position, jump to the definition, and when Ctrl+O is invoked, going back to stored position.

hastebrot commented 7 years ago

Seems VSCode doesn't support this history next/prev functionality. I find nothing in the keybindings.json.

Update: However there are Go > Back and Go > Forward menu entries.

The default (on my system) is:

{ "key": "ctrl+alt+-",            "command": "workbench.action.navigateBack" },
{ "key": "ctrl+shift+-",          "command": "workbench.action.navigateForward" },

A vim-like binding would be:

{ "key": "ctrl+o",         "command": "workbench.action.navigateBack" },
{ "key": "ctrl+i",         "command": "workbench.action.navigateForward" },

But beware this seems a bit sloppy. Maybe this is also mentioned in the VsCodeVim documentation.

monkoose commented 7 years ago

@mswift42 I trully believe that you can implement something what you need with the marks(they are supported in the vscodevim). Not the full ctrl-o functionality, just jump back to the line where you were. Do not tested myself but vscodevim support .vimrc configs so you can do some mark before jump(autoadd it when you press ctrl+]) and then add another keybindig to jump to that mark. At least for now. Or stick with an editor that you work for now and check this feature later. I'm too for now can't work in vscode. But i really like it besides some missing vim features.

@hastebrot Seems like working. At least for first glance(may be has some bugs though do not sure). So my comment is useless.

hastebrot commented 7 years ago

@monkoose I observed some problems with gd, then multiple ctrl-o, then ctrl-i inserts some strange history items inbetween. Or gd, then ctrl-o, then j jumps somewhere multiple rows below.

Update: I could not reproduce the first issue after an update to the newest insiders build. Could be fixed in the update, could also be me trying to reproduce this issue in the wrong files.

Xaeroxe commented 7 years ago

It's been a while since this issue was last looked at, but I did download VSCodeVim today and I am rather pleased with it. It's also offered through the welcome page of VSCode. Therefore I don't see any reason to keep this issue open. Any further enhancement requests should probably go to the VSCodeVim repository.