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.
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!
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!
Copy or cut everything between these quotes / parenthesis / brackets.
Don't know. Never needed to. Trivial with a macro Delete up until the next X character. Now delete up until the next X character again.
Never used it but https://www.gnu.org/software/emacs/manual/html_node/emacs/Ot... M-z char - Kill through the next occurrence of char (zap-to-char). Cut these rows then paste them over there.
Well, select rows, kill, move to new place, yank. Not sure what else you want. Change all instances of "foo" to "bar".
M-S-% - query replace (and variations such as regexp) Show all lines with (or without) "foo".
Erm can only do with, but as in original post, M-s o (occurs) Reformat a line like so, now do it to the 351 line following it.
Not sure your requirements but command align-regexp works for me. Don't know what else you want. Reindent this section of text.
Depends on mode, but select text then TAB key. Go to the beginning of this if() / method / loop.
Don't know. Perhaps Search reverse for { char? Go the the file where this Python / PHP class is defined.
Mode specific. I'd be pretty sure that kind of functionality doesn't come built into vim. I use Omnisharp which does similar but it's an external package. In markdown files, open this hyperlink
mode specific. Presumably also in Vim? Search for the first occurrence of this token in this method.
Just search forward. That may not be quite what you want, maybe. Search for the next occurrence of this word (actually learned to do this today, for the most part)
M-s . when on symbol. Subsequently C-s search forward, C-r searches reverse (backward).But I'm not trying to change your mind, use what suits best.
Edit: M-S h is highlight-regexp which highlights all matches in the buffer in colour (does depend one some mode stuff, but works in most modes).
> But I'm not trying to change your mind, use what suits best.
Quite the opposite, I very much appreciate the engagement. You have likely saved me a few hours as I do intend to learn how to use Emacs properly.Some of the things I see that I was not clear about, but I do not need to belabour and now I've got some great headstarts on the rest. You are correct, some of the functionality mentioned are in fact provided in VIM via plugins.
Thank you.
Suggest grabbing the emacs book https://www.oreilly.com/library/view/learning-gnu-emacs/0596... and/or the emacs manual from https://www.gnu.org/software/emacs/manual/ (free pdf) and go through them. They will repay the time!
Good luck and remember any pro emacs user will trip themselves up to help newbies learn!
> Good luck and remember any pro emacs user will trip
> themselves up to help newbies learn!
I've noticed this. The Emacs community is one of the most welcoming tech communities that I've seen, and have helped accelerate my learning curve tremendously. Thank you.C-x 2 - split window horizontally - bloody useful.
Get used to macros if you haven't already.
Issue part of a command then ? for help eg. M-s ? gives you a family of stuff inc the aforementioned occurs command.
Look up registers. Dead handy. Also look at (IIRC) Bookmark+ (?) which allows you to save your desktop config then reloads it next time you start up.
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.
I don't think I could've persisted long enough had I tried using a vanilla GNU Emacs.
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 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...