reddit / emacs

Robust evil mode? How?

trae · 2022-04-12 18:59
Hi all, On the heels of last week thread about evil mode, I wanted to ask if there's a good guide to getting started with evil? I've been using Emacs with evil mode for a couple of years, but there's always something that seems to be breaking or misbehaving. The latest thing that was bugging me was undo-tree wasn't properly integrated with evil, so sometimes it just wouldn't work - even after I spent time looking into it. I dont need evil in minibuffer, but some commands are just too ingrained now (`dd`, `G`, `/` and so forth) that switching evil mode off is just as painful as keeping it on and living with issues. Is there a robust way to get evil mode going? A guide? Much as I love modal editing my only other option is to embrace emacs way and disable evil.
deltille · 2022-04-12 19:26
What are some of the other things misbehaving? I have a decent chunk of my config committed to 'correcting' evil as well. Can you also clarify what it is you want undo to do precisely? I never used the 'branching' undo feature so I don't want to assume you are the same.
squirelpower · 2022-04-12 19:27
I was also using evil for a couple of years, switched a couple of months ago to meow https://github.com/meow-edit/meow. Its a minimalistic modal packagen Highly recommend trying that out, couldn't be happier with it :)
trae · 2022-04-12 20:04
> Can you also clarify what it is you want undo to do precisely? I'd like it to work :) Joking aside, hitting `u` resulted in some error when using `undo-tree`. I then saw a recommendation for `undo-fu` to integrate undo-tree and evil. It worked for a bit, but would still intermittently throw up errors, so I'd revert to using `Cmd-Z`. I recall having some problem with `evil-goggles`. I *think* it'd pin my CPU for whatever reason. Went away after I disabled. I'm not as proficient in Emacs as I'd like so debugging these issues is currently outside my league. The other very likely scenario is that I'm putting my config together in a way that's suboptimal that's causing these problems.
trae · 2022-04-12 20:05
Thanks for the suggestion. If I'm honest I'm a little bit reluctant to solve my config problem by more configuration :) Do you have an example maybe of how you're configuring/using it?
deltille · 2022-04-12 20:12
Yeah, I feel that last bit. Undo-tree had the same nuisance for me. I more or less accidentally got undo working how I wanted it early on and have been afraid to touch it since: (require 'undo-fu) ;or use-package, however you have yours set up (define-key evil-normal-state-map (kbd "u") 'undo-fu-only-undo) (define-key evil-normal-state-map (kbd "C-r") 'undo-fu-only-redo) I didn't even know about evil-goggles. Neat but I'm not surprised if it was chewing your CPU, I can imagine many ways to write that that would. Maybe it'll help you, my solution for keeping a somewhat debug*able* config while figuring out what I want was to split things out into several files-- the ones loaded first are the most stable code that I need to work, and the rest go down from there in terms of 'need to work' and 'need to actually have' priority. But instead of loading them in my init.el with (load "that config file"), I would use: (eval-buffer (find-file "that config file")) which means that as every file is evaluated, it's also opened as a buffer-- and if it fails, no further ones will be opened. So I can often figure out which tweak was breaking without having to go through the whole 'emacs --debug-init...' headache. emphasis on 'often'... not always.
Ghosty141 · 2022-04-12 21:32
>The latest thing that was bugging me was undo-tree wasn't properly integrated with evil, so sometimes it just wouldn't work - even after I spent time looking into it. Since emacs 28 (which has been available for quite some time now) includes undo/redo functionality this should be "fixed" by telling evil to use that one. >I dont need evil in minibuffer You can turn it off, or what do you mean? I personally use evil only for the text manipulation parts and custom binds for everything else. Making emacs a 1:1 vim copy doesn't work, for me it's a great experience and I don't really have any issues on that front.
Alan_Shutko · 2022-04-12 22:18
Emacs 28 was only released 8 days ago (although protests have been around for a while)
squirelpower · 2022-04-12 22:24
That's understandable :). A big advantage is that one can use a lot of the Emacs bindings but in an evil-esque way. You can see my bindings here: https://gitlab.com/niklaseklund/dotfiles/-/blob/master/.config/emacs/lisp/ne-bindings.el
trae · 2022-04-12 22:25
> You can turn it off, or what do you mean? What I meant to say is, I don't need 100% VI bindings everywhere. But I couldn't make it work well enough, but that's probably on me.
ideasman_42 · 2022-04-12 22:48
Check this answer for configuring the undo system for evil-mode: https://emacs.stackexchange.com/a/62726/2418
TelcDunedain · 2022-04-13 00:31
It seems like what you are asking for is this - https://github.com/emacs-evil/evil-collection It works well but pay attention to what modes it actually implements. I sometimes pick modes based on whether has built a nice evil-collection mode for it.
JoshuaOC · 2022-04-13 07:29
I had the same issue, and my solution was ditching Evil. Can only speak for myself, but its been fine actually. Default Emacs keybindings + some nice extras (expand-region) are expressive enough for me that I don't feel slow trying to do what I want. Maybe I am arguably slower at editing, but that is almost never the bottleneck for me (for prose or code).
pajuch · 2022-04-13 10:04
[The only way...](https://github.com/emacsorphanage/god-mode)
onetom · 2022-04-13 11:31
100% same experience. I used vim for 7 years when I was younger and mostly did sysadmin work, but after I got back to programming (for the past ~2 decades) I gave up on vim bindings. Eventually I got bothered by having the cursor keys so far way from the home row, so I started experimenting with custom mechanical keyboards and designed some QMK layouts for MiniDox, Signum 3.0 & Ergo Dox EZ. I never found enough time to get accustomed to them though :( Meanwhile, I stumbled upon the SpaceFn layout, which put the cursor keys into Space+IJKL. I'm using it for ~4 years now and it's freaking amazing! I've implemented it software, using Karabiner Elements + @jeebak's complex modifications: https://ke-complex-modifications.pqrs.org/?q=jeebak It has a bunch of other conveniences, Space-Q means Cmd-Tab and Space-W Opt-Tab. Mapped Backspace to Space-P, Caps Lock to both Ctrl and Esc (which still results in undesired Esc a few times a week) This saved a loooot of time, which I would have spent on trying to make vim-style navigation work everywhere. I do use vimera/vimium in browsers though... and use both J/K and Space-I/K, depending on my mood. I do feel it's easier to just use J/K, but using H as left is just ridiculously painful for me, compared to Space-J I use IntelliJ most of the time, but for the past 3 years I'm constantly learning, configuring and practicing Emacs and I suspect I will adopt something like god-mode, meow or lispy eventually, but meanwhile I definitely do not miss vim-style editing.
onetom · 2022-04-13 11:36
vim-style editing for me started to feel like I'm doing CISC assembly live-coding, just to edit the text of the actually program I'm writing (usually in Clojure). Using non-vim style and chorded shortcuts, still sometimes feels like assembly live coding, but at least for a RISC processor, because I use a lot less keyboard commands and combine them in trivial ways, which causes perceptibly less mental overhead.
onetom · 2022-04-13 11:41
And yes, `expand-region` FTW, especially when combined with allowing to override the active region with self-insert-char. Well, in practice I'm using IntelliJ's equivalent "Expand/Shrink selection" feature, bound to Opt-UP/DOWN (which is Space-A-I/K on my layout)
bravosierrasierra · 2022-04-13 13:59
my last resort solution for evil-unfriendly modes: (global-set-key (kbd "M-h") 'backward-char) (global-set-key (kbd "M-j") 'evil-next-line) (global-set-key (kbd "M-k") 'evil-previous-line) (global-set-key (kbd "M-l") 'forward-char) (global-set-key (kbd "M-y") 'bss/first-non-blank) (global-set-key (kbd "M-o") 'bss/end-of-line)
trae · 2022-04-13 14:15
> You'll find this mode surprisingly natural, as you would already know how to use your existing Emacs commands. Part of the problem, is that I live in a mixed emacs/vi universe :D
trae · 2022-04-13 14:17
After reading everyone's comments I think this is the only way for me. I don't want to mess with this anymore.
redguardtoo · 2022-04-14 16:11
You could focus on what Emacs can do for you. A bit Lisp knowledge is also helpful. Maybe you could use my distribution (https://github.com/redguardtoo/emacs.d), see how I customize evil. For example, undo is not important to my workflow because I uses lots of git commands. So every tiny snippet I write will be in git (maybe some branch) very soon. If I need revert some code, I use `magit` or `vc` in Emacs.