emacs-evil / evil-magit

Black magic or evil keys for magit
https://github.com/justbur/evil-magit
GNU General Public License v3.0
273 stars 16 forks source link

evil-visual-char Request #26

Open jojojames opened 7 years ago

jojojames commented 7 years ago

When using (setq evil-magit-want-horizontal-movement t), sometimes (most of the time), I'd like to be able to select the text I want to yank with v, but both v and V go to evil-visual-line.

If there are no downfalls, could we get a setting to get the old 'v' functionality?

Thanks!

justbur commented 7 years ago

This has been discussed and is a little more complicated than it first seems. I can give more details, but the main problem is that magit is basically line based, and you typically can't take actions on parts of lines.

With line selection, V, you can still take magit actions seamlessly. For a simple example, Vjjl brings up the magit log popup, meaning you do not move the cursor forward with l in "visual state". Of course, it's not really visual state anymore because of this. Presumably vjjl would behave differently under your proposal and this is confusing I think.

One way to do what you want already which is not "evil-like" is to enter into what I called text-mode with C-t. You can do this in any magit buffer using evil-magit. After C-t everything is just text and you can copy and move around as you like.

I can look into other options, but again this will almost surely involve introducing inconsistencies.

jojojames commented 7 years ago

Thanks for the explanation.

I don't normally enter visual state when using magit commands (not familiar with the commands that operate on multiple lines in magit), so for me, entering visual state almost always means I'm trying to work with the text itself.

I'll try out C-t and see how it works for me.

justbur commented 7 years ago

One thing I was thinking about would be to have v not shadow the selection/movement and other evil commands, and reserve V for selecting and operating on lines using magit commands. This still seems a little awkward but it makes sense to me.

By the way, the commands the operate on lines in magit can be useful. For example, you can stage a subset of lines from a hunk.

jojojames commented 7 years ago

That's be an interesting option to try. I think there's a lot of value from being able to copy certain text while inside magit so even if it's a little awkward, it'd probably be worth adjusting to.

Right now I just copy the entire text, paste it in a scratch buffer and then copy the values out of that.

You're right about the stage commits. That's what I use it for too.

justbur commented 7 years ago

It's going to be tricky to do this, because visual-line and visual-char both share the same underlying keymaps by default. Getting one set of bindings after visual-char and another after visual-line would I think involve some somewhat complicated trickery.

Try the text mode thing with C-t. Conceptually I think it works well, because after C-t all of the typical evil bindings become active across all of the states. You can move around the same way in normal and visual states with f for example.

jojojames commented 7 years ago

Thanks, I'll give that a shot then.