johtela / vscode-modaledit

Configurable Modal Editing in VS Code
https://johtela.github.io/vscode-modaledit/docs/README.html
Other
89 stars 8 forks source link

Presets, including a Vim Preset #7

Closed brillout closed 3 years ago

brillout commented 4 years ago

Hi @johtela !

I'm a long-time Vim user and I just started to use VS Code because I'm starting to use TypeScript.

What you are building looks really nice, it seems to me that you're onto something.

What I like:

In a nutshell, ModalEdit simply adds a modal mode and gets out of the way otherwise. That's exactly what I'm looking for; I want to fully embrace vscode while having the modal efficiency that I have grown to love with vim.

Am I right at depicting your vision?

Anyways, back to the topic.

My fingers are hard-coded to a bunch of Vim shortcuts; I'd like to start using ModalEdit with a Vim Preset that presets the most common vim keybindings. Over time I'd like to diverge from Vim keybinding to my own.

What do you think of adding presets? For people like me coming directly from vim, a vim preset would be super convenient to get started quickly. In the future it would be nice to have a multitude of presets that can be combined. For example:

At day 20 I have 3 presets and the last "Romuald Preset" overrides all previous presets.

What do you think?

Delapouite commented 4 years ago

Your approach definitely makes sense.

But it should be packaged with some disclaimer, saying that the vim preset only covers the basics and do not intend to be a perfect emulation. Because unfortunately people can be very nitpicking about vim implementations in editors and would complain that this particular feature is missing or the behavior is not 100% the same than in the "one true vim". The end goal should be that it does not turn into a burden for the maintainer of the preset.

brillout commented 4 years ago

@Delapouite Good point & I agree. Personally, I don't want a perfect clone but I'd love something better! Hehe :)

brillout commented 4 years ago

I'd love something better

Which actually would already be the case with 100% VS Code insert mode + basic vim commands in normal mode

johtela commented 4 years ago

Hi @brillout,

Thanks for the positive feedback. You are 100% right about the vision. The idea of ModalEdit is to enable Vim features without changing the core functionality of VS Code. You are also correct in assuming that insert mode works as vanilla VS code without the extension.

Regarding presets, the basic Vim commands are (kind of) already available here. This is the literate source file of the tutorial page. These bindings do not cover all the possible Vim commands that you can emulate with ModalEdit, but they should give you an idea how to implement the missing features.

I can definitively see the need for having sensible presets. As you start with a blank slate, there is quite a lot of work involved in getting you up and running. But I would not want to impose those presets automatically to all users, they should be something you opt-in to.

The thing is, although ModalEdit is not meant to be a Vim clone, people finding it useful are mostly Vim users who have migrated to VS Code, and are dissatisfied with existing emulations. That was my motivation, anyway 😉 So, it makes sense to cater for these users. In fact, I am currently thinking of a simple way to add Vim's "repeat last change" command to ModalEdit. But as @Delapouite pointed out Vim users tend to be very picky that things work exactly like in Vim, and providing a full Vim emulation out-the-box is not a goal of ModalEdit. Presets should be just a starting point or example to teach you how to define your own bindings.

If you have any ideas or suggestions how these presets could be distributed or deployed, let me know. The simplest option is to expand the bindings in the tutorial and make them available in GitHub (without the comments). I could also include some additional examples that contain bindings that I have found useful myself (my own bindings are available here).

brillout commented 4 years ago

I agree with everything you say :-).

How about the following?

A modaledit directory next to settings.json with following files:

// mdaledit/modaledit.js

module.exports = {
  presets: [
    './vim.js',
    './johtela.js',
  ],
};
module.exports = {
   keybindings: {
     // vim preset copy pasted from github.com/johtela/vscode-modaledit
  }
};

To keep things simple at the beginning, the user would copy paste the Vim preset from a file in this repository.

I purposely made these file JavaScript files and not JSON files, see #9.

johtela commented 4 years ago

Thanks for the suggestions. Since doing a semi-complete implementation of Vim keybindings is quite a large undertaking, I can't promise it will be ready soon. I will try to include them to the next minor release.

brillout commented 4 years ago

That would be absolutely amazing.

It takes time to change hard-wired typing habits and a Vim preset would help a lot.

semi-complete

Personally, I'm totally fine if only the most useful Vim keybindings are supported. Anything I can do with vscode, I'd rather do with vscode directly. For example I'd rather use vscode's multi cursor feature than something like vim's macro.

And actually, to me, what you did in https://raw.githubusercontent.com/johtela/vscode-modaledit/master/.vscode/settings.json is almost it. I'm currently using this "preset" and I'm already fairly happy. The only thing I'm missing are the "ci", "di", and "yi" features.

Beyond that, I'm looking forward to "progressively migrate" towards your modal editing world :-).

johtela commented 3 years ago

Vim presets are included in version 2.0. See the documentation for details.