Live data from Hacker News

The extensible vi layer for Emacs

github.com

71–80 of 104 posts

Re: The extensible vi layer for Emacs

#72
post #63

Earlier quoted context omitted.

So I fired up Emacs: emacs -q M-x viper-mode RET Chose expert level 1 for beginners so that it is closest to Vi behavior. (Recommended level is at least 3 but that does not make a difference for what I am about to explain.) C-x C-f foo.txt RET i hello world RET hello world RET hello world RET ESC Looking good so far. gg Does nothing!! Okay no problem. Let me try: :0 RET Good. I am back to the top line. V Instead of s…

Yes, gg and v/V appear to be vim-only commands. One vi counterpart to gg is 1G. Visual mode is a vim-only concept, I believe. The rest of them, I would bet are vim-only. Yes, I can see why, if you require all of these vim features, viper would not be good for you. "Viper mode is terrible though." was not a good way to express this. The title of the thread, and the name of the package (incorrectly) state that it is a…

I should add that I would love to see viper mode enhanced to (perhaps optionally) support some vim functionality, and I admit I would find it silly if someone said that viper should only ever support strict vi functionality. But I would also be sad if people used the existence of Evil as a reason to declare viper dead.

Re: The extensible vi layer for Emacs

#73
post #63

Earlier quoted context omitted.

So I fired up Emacs: emacs -q M-x viper-mode RET Chose expert level 1 for beginners so that it is closest to Vi behavior. (Recommended level is at least 3 but that does not make a difference for what I am about to explain.) C-x C-f foo.txt RET i hello world RET hello world RET hello world RET ESC Looking good so far. gg Does nothing!! Okay no problem. Let me try: :0 RET Good. I am back to the top line. V Instead of s…

Yes, gg and v/V appear to be vim-only commands. One vi counterpart to gg is 1G. Visual mode is a vim-only concept, I believe. The rest of them, I would bet are vim-only. Yes, I can see why, if you require all of these vim features, viper would not be good for you. "Viper mode is terrible though." was not a good way to express this. The title of the thread, and the name of the package (incorrectly) state that it is a…

> "Viper mode is terrible though." was not a good way to express this.

Agreed and thanks for calling it out. Will be more careful next time.

Re: The extensible vi layer for Emacs

#74

I used that settings for a few years, then tried to move entirely to vim, and now I'm very happy with vscode + vim. I like vim as a touch typer, I think it's a setting that minimize end motions. It's also very convenient in the terminal. On the other hand, I think it's not convenient as an IDE: too many shortcuts, clumsy integration with LSPs, especially when you need to work with different languages. For me it works…

> That being said, I wonder if I wouldn't be better off moving away from vim entirely That's a surprising sentence to read, as someone who's also used to vim (although I've moved from vim to emacs+evil and not the other way around). I have some gripes with my emacs+evil setup, just as I had some gripes with my vim (and then neovim) setup. But none of those gripes were related to the actual text editing, but rather ma…

> That's a surprising sentence to read, as someone who's also used to vim

Well, I feel modal editing is "comfortable", as in easy on the fingers. But overall, I'm also quite fluent with the mac os shortcuts. Maybe it's just a matter of learning the few things I don't know how to do without vim and I'd be equally happy. The added bonus would be to have a simplified set up that would work in every contexts where vim isn't available. That being said, it's not something I want to do actively as I'm happy with my set up, but just wondering if the benefit is real.

Re: The extensible vi layer for Emacs

#75

There's also meow-mode[1], which isn't a vim emulator as such, but it is a different modal editing layer for Emacs which is a lot faster and has a lot of neat ideas. It doesn't interfere w/the stock keybinds at all though, which is much nicer imo (I use a 'hybrid' editing style generally) 1: https://github.com/meow-edit/meow

I've been seeing posts about packages like God Mode, Boon, and Meow[1] for a long time, and just haven't set aside time to check Meow out yet bit am very exited to c:

1: https://esrh.me/posts/2021-12-18-switching-to-meow.html

Re: The extensible vi layer for Emacs

#78
It's not evil but there is also a built in emulation for vi called viper.

I've never used it to emulate vi but I have used it to emulate ex, which is a part of vi. I don't know if anyone else feels this way but when I started with emacs a long time ago I thought that ex commands were much more productive for things like searching and replacing. For anyone who knows vi, that is for example :%s/regex/replacement/

So I just bound the ex prompt to C-c :

Maybe emacs does better for search/replace these days. What do others think?

Re: The extensible vi layer for Emacs

#80

It's not evil but there is also a built in emulation for vi called viper. I've never used it to emulate vi but I have used it to emulate ex , which is a part of vi. I don't know if anyone else feels this way but when I started with emacs a long time ago I thought that ex commands were much more productive for things like searching and replacing. For anyone who knows vi, that is for example :%s/regex/replacement/ So I…

For search and replace, the ex substitute command (:%s/pattern/string/[flags]) does feel more convenient and flows out smoothly from the fingers while typing such a command. For search and replace operations, it is indeed very productive.

However the incremental search (C-s) of Emacs goes much further than that. It is packed with features. While it has too many features to enumerate in one comment, I'll just pick one thing about it that I have found useful and quite enjoyable. It is the set of various toggles Emacs incremental-search comes with. Some of those toggles turn out to be very useful in special circumstances.

Say, I have a source code file that is doing some regex-based work. Both the regex "f.." and the strings it matches like "foo", "fox", etc. occur in the file. Now say, I want to search for the regular expression pattern "f.." (not the strings it matches). I can of course do that simply with:

  C-s f..
After searching for that regular expression, I decide that I now want to search for strings that match the regex pattern "f..". Now I can simply change the string search to regex-based search with this toggle:

  M-r
As another example, let us say, I start searching for the string "web_server" with this key sequence:

  C-s web_server RET
But then I realize that the current code has the words "web" and "server" written together in all kinds of notation like "web->server", "web::server", "web-server", etc. and now I want to match all of them. In Vim, I would have to cancel the current search and write a new search expression, perhaps something like /web.\{1,2}server or maybe /web[-_:>]\+server depending on what we need. In Emacs, I can do it with this toggle:

  M-s w
And now it would match "web->server", "web::server", "web-server", etc. I know you specifically mentioned search-and-replace, not just search. The conveniences I illustrated above are available equally well in search-and-replace too because converting a currently ongoing search to search-and-replace in Emacs is yet another toggle:

  M-%
Post reply on HN