Live data from Hacker News

Show HN: Build your own Vim emulation for VS Code

johtela.github.io

31–40 of 51 posts

Re: Show HN: Build your own Vim emulation for VS Code

#31
post #14

Earlier quoted context omitted.

OP here. I completely agree with that. The goal of ModalEdit is not to emulate those verb-noun commands. VS Code's commands operate on selections, so it is very cumbersome to turn them to work in Vim way. Instead, you should try to mimick something like [Kakoune][1] which is another modal editor that uses the selection as command target. I'm sure ModalEdit doesn't tempt any hardcore Vim users to use VS Code. But ther…

Well, this certainly looks interesting. You mean I could use ModalEdit as a basis to bringing Kakoune like selection behaviour to VS Code as long as I'm willing to configure it? I have played with Kak, but Code's extensions are easier to use and more powerful still. I so very much would like to get the best of both. Have you used Kakoune yourself? Is there something that's currently not feasible with VS Code using Mo…

“Dance” is a VSCode extension that provides Kakoune inspired key bindings. I have tried it but have never seriously used it. Will give ModalEdit a try.

https://marketplace.visualstudio.com/items?itemName=gregoire...

Re: Show HN: Build your own Vim emulation for VS Code

#32
post #14

Earlier quoted context omitted.

OP here. I completely agree with that. The goal of ModalEdit is not to emulate those verb-noun commands. VS Code's commands operate on selections, so it is very cumbersome to turn them to work in Vim way. Instead, you should try to mimick something like [Kakoune][1] which is another modal editor that uses the selection as command target. I'm sure ModalEdit doesn't tempt any hardcore Vim users to use VS Code. But ther…

Well, this certainly looks interesting. You mean I could use ModalEdit as a basis to bringing Kakoune like selection behaviour to VS Code as long as I'm willing to configure it? I have played with Kak, but Code's extensions are easier to use and more powerful still. I so very much would like to get the best of both. Have you used Kakoune yourself? Is there something that's currently not feasible with VS Code using Mo…

I have to admit that I haven't used Kakoune myself. I just like its approach of taking the good parts of Vim and adapting them to more "mainstream" style of editing.

Because Kakoune's editing operations are much closer to VS Code than Vim's, I think you can copy its functionality quite extensively with ModalEdit. The only limitation is that VS Code itself needs to have the commands to support these operations. The configuration involves just binding key sequences to the commands. However, VS Code marketplace has so many command extensions, so I bet you can find substitutes for most Kakoune features there.

Regarding the literate configuration, there is no Jupyter-style online editor for it, afaik. I use (of course) VS Code to edit my `settings.json` file. In the background I run [LiTScript][1] in watch mode to generate the documentation on the fly. I also use the [Live Server][2] extension to automatically reload the generated documentation when it has been changed. With this setup, saving the `settings.json` file causes VS Code to reload the configuration, LiTScript to generate the updated documentation, and Live Server to reload it automatically. So, it is almost like Jupyter in the sense that you see your changes in effect immediately.

[1]: https://johtela.github.io/litscript/ [2]: https://marketplace.visualstudio.com/items?itemName=ritwickd...

Re: Show HN: Build your own Vim emulation for VS Code

#33

Why use VSCode at all then? I've found coc.nvim and language servers to be every bit as good as VSCode in terms of code completion and definitions. I'm mostly writing Go, C, Javascript, and HTML/CSS. But, so far it's been working great. And, I'm a fairly recent convert to vim (neovim).

I use Vim but one thing that VSCode has that Vim does not is the idea of remote containers.

With VSCode, it's pretty nice and easy to get perfect auto-complete, definitions, etc. from code running in a container.

With Vim, AFAIK there's not anything near as seamless to do the same thing. In fact, I've found nothing that even tries to do it.

Re: Show HN: Build your own Vim emulation for VS Code

#34
post #13

Why use VSCode at all then? I've found coc.nvim and language servers to be every bit as good as VSCode in terms of code completion and definitions. I'm mostly writing Go, C, Javascript, and HTML/CSS. But, so far it's been working great. And, I'm a fairly recent convert to vim (neovim).

For those that are unaware, it’s literally the same system underneath. Vscode talks to language servers to do all the work and they’ve architected the system in such a way that others can talk to them too. Coc.vim provides the plumbing to do that from vim. It’s a great project. Took me a while to get things configured properly but it’s been great for doing all my typescript work.

Is anyone aware of an 'opinionated' neovim distribution?

Something like spacemacs or Emacs Live, that takes care of all the configuration work to give a solid basis out of the box.

I've been dragging my feet on switching everything to nvim because I don't have 'awhile to get things configured properly' these days.

Re: Show HN: Build your own Vim emulation for VS Code

#35
post #2

This is an interesting approach. I find the popular vim emulation extension (vscodevim) is a bit buggy and has lots of "uncanny valley" gaps. At work I use vscodevim, and at home I use vim with TypeScript plugins. Both approaches have lots of annoyances. Maybe a weekend dedicated to ModalEdit could give me the experience I'm really after. I'm also excited for Oni Vim 2, which is a commercial product who's promise is…

Your take on vscodevim is a sort of "glass half empty" kind of argument. To be fair, vscodevim is fantastic and it gets a lot more thing right than it gets wrong.

Re: Show HN: Build your own Vim emulation for VS Code

#36

Earlier quoted context omitted.

Well, this certainly looks interesting. You mean I could use ModalEdit as a basis to bringing Kakoune like selection behaviour to VS Code as long as I'm willing to configure it? I have played with Kak, but Code's extensions are easier to use and more powerful still. I so very much would like to get the best of both. Have you used Kakoune yourself? Is there something that's currently not feasible with VS Code using Mo…

“Dance” is a VSCode extension that provides Kakoune inspired key bindings. I have tried it but have never seriously used it. Will give ModalEdit a try. https://marketplace.visualstudio.com/items?itemName=gregoire...

Thanks. There's also https://github.com/reykjalin/kakoune-mode which sends input from VS Code to Kakoune and shows its output back within Code. I haven't tested it yet, though.

Re: Show HN: Build your own Vim emulation for VS Code

#37

It's disappointing to see from comments here that there's no true and performant Vim integration for VS Code. It used to be the same thing with Eclipse and JetBrain's IDEs. Whatever Vim plugins existed were slow and falling into the uncanny valley, where they lacked support for many features or did things in slightly unexpected ways. Torn between Vim and effectively Vimless IDEs, I chose to stick to the former and do…

As a completely biased user/person who is insane enough to adopt an editor as a lifestyle, I've been using a vim emulation layer for Emacs (Evil) and I've in a sense gotten used to it.

That comes after dozens of hours twiddling around with configuration files that let you set leader-based keybindings and change pretty much every aspect of how the vim emulation behaves. And after using it for a while I've found it behaves pretty much exactly like vim, which in itself is a godsend in a plethora of vim emulation plugins that don't get everything quite right. Somehow it just works how you'd expect. If lsp-mode becomes stable enough we might live to see "IDE"-like features in Emacs being workable.

I wouldn't recommend this approach for everyone, though. Because most of Emacs was not designed to use vim emulation you often have to switch between plain Emacs and the vim layer really often, or even worse write entire keymaps for unsupported features. When you have to do this depends on the functionality you want to use, and this is variable enough that it's not possible to immediately get used to - you have to learn how everything works first and adapt your muscle memory/config to it.

Evil is also baked into Emacs, so you'd have to use Emacs with its 44 years of cruft and get used to its unique methodology to take advantage of it. People may either become disinterested in this or completely entranced by it (see: the author). Either way, you'd be spending time learning a lot of new editing paradigms instead of doing actual work.

Also Emacs is slow when opening and searching big files, and this stems from a fundamental decision about how Emacs stores open files in memory. In those cases I have no choice but to open a minimal vim to edit them.

In addressing the slowness problem the xi editor[1] is trying to move in the direction of never blocking the user's input and separating frontend/backend. However, last time I checked the JSON-RPC they were using was not performant enough for their needs. There was also a huge debate on how to do collaborative editing, and the problem they eventually stumbled upon was that in some cases you'd have no choice but to essentially do the same thing as git merge does to resolve editing conflicts. Also because the protocol is so generic people ended up creating dozens of frontends in several different languages that support different feature sets instead of combining all their effort into making an even better standardized client.

Text editors are at the same time universal and full of tough issues to solve. It is indeed a shame that the programs that are most capable of running programs lack good text editors, and vice versa. One time I got fed up with having to constantly use the mouse when using IntelliJ so I wrote an LSP server embedded as an extension so it could be controlled from emacs. Unfortunately I didn't have the time to constantly keep up with the internal APIs that broke every few weeks and fix all the edge cases.

[1] https://github.com/xi-editor/xi-editor

Re: Show HN: Build your own Vim emulation for VS Code

#39
post #32

Earlier quoted context omitted.

Well, this certainly looks interesting. You mean I could use ModalEdit as a basis to bringing Kakoune like selection behaviour to VS Code as long as I'm willing to configure it? I have played with Kak, but Code's extensions are easier to use and more powerful still. I so very much would like to get the best of both. Have you used Kakoune yourself? Is there something that's currently not feasible with VS Code using Mo…

I have to admit that I haven't used Kakoune myself. I just like its approach of taking the good parts of Vim and adapting them to more "mainstream" style of editing. Because Kakoune's editing operations are much closer to VS Code than Vim's, I think you can copy its functionality quite extensively with ModalEdit. The only limitation is that VS Code itself needs to have the commands to support these operations. The co…

Thank you. I'll be sure to check ModalEdit. Since VS Code is so easy to extend I guess I'll just have to find what things to copy over from Kak. Since Kak can be used as a server also (https://github.com/mawww/kakoune/wiki/JSON-RPC) I can send stuff over to it for more extensive editing.

I'll check the LitScript also. Yours sounds like quite a workable workflow.

Re: Show HN: Build your own Vim emulation for VS Code

#40

It's disappointing to see from comments here that there's no true and performant Vim integration for VS Code. It used to be the same thing with Eclipse and JetBrain's IDEs. Whatever Vim plugins existed were slow and falling into the uncanny valley, where they lacked support for many features or did things in slightly unexpected ways. Torn between Vim and effectively Vimless IDEs, I chose to stick to the former and do…

> It's disappointing to see from comments here that there's no true and performant Vim integration for VS Code. I've been using vscodevim daily for almost 2 years, and (for me) it's totally usable. IMHO, much better experience than trying to turn Vim into an IDE.

Yep. It's not 100% perfect, but it's good enough.

Of course it's also be great if I could figure out why my language server plugins for Vim cause the entire editor to freeze up for a few seconds periodically despite running asynchronously, or why my intellisense menu plugin flickers like crazy every time I pull it up. But the ways in which VsCodeVim don't work for me are more conducive to getting things done than the ways Vim doesn't work for me.

Post reply on HN