by jgilias · 6y ago · 0 comments
Man...
Any comparison between the two is completely besides the point. Vim is a great text editor that one can extend. Emacs is a computing environment that happens to revolve around text. The tools are simply in different categories altogether.
Emacs is a text editing platform, but its text editing language is good for writing only. Not good for editing, not good for copying or moving code, not good for navigating, not good for working with brackets or parenthesis despite the lisp language being almost native to Emacs.
My recent exploration into org-mode introduced me to Evil. It's 95% of the VI language, in an amazing text editing platform. I'm currently only using Emacs for org-mode right now, but suddenly new worlds are opening. For instance, I've been looking for a good tool to navigate CSV files from the CLI (or any other keyboard-controlled environment) for over two decades. I'm not yet explored the possibilities with Emacs, but I'm told they are good. Then possibly browsing simple websites, such as HN and Wikipedia, maybe a better Git interface, maybe a good Telegram / Slack / IRC combined messenger, maybe a good email reader.
Suggestions welcome!
I knew Emacs wasn't the editor for me when I found out that there isn't, by default, a way to quickly duplicate a line. Of course, the emacs community says that adding this feature is a simple matter of defining a macro in your emacs config file. Very different mindset.
Let's see:
; Duplicates the current line
S-C-backspace C-[y y]
; Duplicates the current line
C-[a k k y y]
; Duplicates the current line
C-[a SPC n w y y]
; Duplicates the current line
C-[a SPC n] ESC w C-y
Repeat duplicating until it looks like enough: ; Duplicate again until happy
C-[y y y...]
; Duplicate again until happy
C-x z z z...
Duplicate 3 lines instead of 1: ; Duplicate this line and the next two
C-[a u] 3 C-[k y y]
Duplicate 10 times: ; Duplicate the current line 10 times
C-[a k k] C-x ( C-y C-x ) C-u 10 C-x e
; Duplicate the current line 10 times
C-[a SPC n w] C-x ( C-y C-x ) C-u 10 C-x e
; Duplicate the current line 10 times
S-C-backspace C-x ( C-y C-x ) C-u 10 C-x e
Remove duplicate lines instead: ; Select region, then
M-x delete-duplicate-linesI don't think I could've persisted long enough had I tried using a vanilla GNU Emacs.
Hmm. OK, I wonder why. For me M-h selects a a paragraph. Repeated M-h selects further. M-w copies it. S-M-{ or S-M-} to jump by paras.
M-s . for symbol lookup. In that family you can do highlight regexp or line.
M-s o - get an overview of every line that matches what you want ('occurs')
etc. etc.
Macros, registers (using these to store large chunks of text, basically class templates). etc.
* Copy or cut everything between these quotes / parenthesis / brackets.
* Delete up until the next X character. Now delete up until the next X character again.
* Cut these rows then paste them over there.
* Change all instances of "foo" to "bar".
* Show all lines with (or without) "foo".
* Reformat a line like so, now do it to the 351 line following it.
* Reindent this section of text.
* Go to the beginning of this if() / method / loop.
* Go the the file where this Python / PHP class is defined.
* In markdown files, open this hyperlink
* Search for the first occurrence of this token in this method.
* Search for the next occurrence of this word (actually learned to do this today, for the most part)
These were just example off the top of my head in a few seconds, none of which had an easy answer in Emacs. Sure, I could spend ten minutes each to look for how to do each one. I probably did that during the Clinton administration with VIM, before one could just google their problems away. But in VIM, each one has an easy answer and most are actually built right into VIM with no customization necessary. In Emacs, I could implement that stuff but then I'll be implementing everything else I need.So I use Evil!
I like thinking of Emacs as a running Lisp REPL that fires off different functions depending on what key I press. If you haven't seen this already yet, run `C-h k` (describe-key) which will tell you the Emacs Lisp function behind a particular keystroke. You can then call that function directly with `M-: (emacs-function-here) RET`.
In think they called it that way because you do use the space key very often. Much like in the game.
Exactly what I thought when I switched from Vim to Emacs a few days ago. They are not comparable, I was mind blown when discovering Emacs. Of course the first thing I installed was Evil, but they are two entirely different beasts indeed!
Enjoy your emacs journey mate ;)
And it’s usually embedded in another computing environment that happens to revolve around text called UNIX. If only the scripting language of the latter was as elegant as Lisp...