this post was submitted on 07 Apr 2024
10 points (81.2% liked)

Emacs

2194 readers
1 users here now

Our infinitely powerful editor.

founded 4 years ago
MODERATORS
 

As a long time Vimmer, I have recently started using Emacs out of sheer curiosity. I chose Doom Emacs as it has evil-mode enabled by default, and do not want to dive down the rabbit hole of configuring the editor from scratch (at least, not yet!).

After installing and enabling libvterm in Emacs, I am having a frustrating experience. I configured ZSH shell to use vi-mode keybindings which interferes with evil-mode whenever I press Esc or C-[.

After having searched a little, I came across a workaround to disable evil-mode when in vterm. But it is still not a smooth experience. For instance, when switching between buffers (C-w C-w).

I would like to know how others in the community tackled this problem. Is there a better solution to this problem? Or have you made peace with the aforementioned workaround? Or have you stopped using vterm entirely?

top 13 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 7 months ago (1 children)

Not really an answer to your question, but personally I resolve issues relating to vi keys in Emacs by just knowing the Emacs bindings as well. When I came back to Emacs, I took a month to just use the vanilla bindings. It was painful for about a week, but boy did it pay off; not just for using Emacs (especially for niche packages that don’t have evil mode bindings), but also for other GNU programs like bash and midnight commander and such (as well as, as you mentioned, the defaults on zoomer-shell).

[–] [email protected] 1 points 7 months ago

That is an interesting perspective. Gain a middle ground by learning the bindings of both editors, though a little taxing.

I know that I don’t want to lose on the vim motions skills I learned. So this might be a good option.

[–] [email protected] 2 points 7 months ago (1 children)

Vterm was so integral to my workflow that I finally abandoned vim and learned the default key bindings.

Totally worth it too. I got rid of so many extra packages adapting things to evil mode

[–] [email protected] 2 points 7 months ago* (last edited 7 months ago) (3 children)

That’s an extreme workaround. How do you feel about abandoning the vim motions? Does emacs way of moving and editing stand up to vim motions?

One of the reasons I liked vim motions is that I find it very logical to move around and edit text.

I find it weird that one has to keep holding one or two modifiers to unleash true power of Emacs. Perhaps, that’s just my bias.

[–] [email protected] 2 points 7 months ago (1 children)

How about incremental search (C-s) or some external packages like avy?

[–] [email protected] 2 points 7 months ago* (last edited 7 months ago) (1 children)

I never really tried using incremental search (avy or vim-easymotion) for minute navigation. I will certainly try this approach without evil-collection, along with the package you suggested.

But I can already see it being slightly more time consuming as in my experience with vim-easymotion (and similar plugins like vim-sneak), the “jump” labels aren’t really generated in a logical manner such that I can effortlessly predict the label for the word I intend to bring the cursor/caret to. :-S

How’s your experience with using this for minute navigations?

[–] [email protected] 2 points 7 months ago

I stick with C-s (similar to vim's /) because of the exact reason you said, and I'm happy with C-s.

Please note that C-s <some characters> RET moves the cursor at the end of the target (/ moves it at the beginning). If you don't like the behavior, see this post (I use C-s ... C-r RET in that case).

[–] [email protected] 1 points 7 months ago (1 children)
[–] [email protected] 1 points 7 months ago

I read the paper in its entirety. Thank you so much for sharing it.

I really like the insight shared therein. Specifically on how much thought goes into keybindings, or rather must go into keybindings.

Unfortunately, I don’t think EXPRES is widely supported as the authors hoped.

As intuitive and similar to vim motions EXPRES may be, I don’t want to configure keybindings every time I install a plug-in/module.

[–] [email protected] 1 points 7 months ago (1 children)

@AusatKeyboardPremi
It's a mental burden to keep track of modes. That's why people invented modifier keys in the first place. But I admit after a while there can be too much shortcuts and then something needs to be done about it. I recently transferred my less-often used shortcuts into hydras so I don't need to remember them (and hydras resemble modal operations)

In Emacs, there are no modes the user needs to be aware of when typing where the cursor is.

@aport

[–] [email protected] 1 points 7 months ago

Thank you for introducing me to hydra. I am definitely learning this. It even has a vim port! :-)

[–] [email protected] 1 points 7 months ago* (last edited 7 months ago) (1 children)

My basic approach is: Esc works like in normal evil-mode, and takes me into vterm-copy-mode as well. Without doing that, I have C-w C-w remapped to move to another window, so I can switch to another window for all the rest of my keybindings. And I have C-Esc mapped to send Esc into the terminal itself.

I'm using evil-collection for the basic bindings, and I have my own custom stuff here: https://github.com/bricka/emacs.d/blob/main/init.el#L1054-L1073

Edit: Forgot C-Esc

[–] [email protected] 1 points 7 months ago

Thanks for the tip as well as your configuration.