Live data from Hacker News

Emacs and Vim

martinklepsch.org

71–80 of 277 posts

Re: Emacs and Vim

#71
post #8

Earlier quoted context omitted.

But that means your fingers have leave home row! :(

Thankfully I am blessed with the ability to move my forearms. I've heard a lot of people talk about keeping their fingers on the home row, and I more or less do that when I'm typing text like this, but for general navigation? I've sat next to a number of people who do it, and I get around my editor faster than they do. Based on this anecdotal evidence, I don't think moving my hand a short distance to reach another ke…

Then how do you move multiple lines at a time (4, 16, 64, 256)? To move 16 lines down, I press C-u C-u C-n (of course, the control key stays down the whole time). You either have to press C-u C-u then move your forearm to the arrow key and press down, or press the arrow key 16 times.

(Each C-u is a power of 4. You can specify any number by typing it after the C-u, for example C-u 100 C-n to move down 100 lines.)

Re: Emacs and Vim

#72
post #19

Until it goes wrong or you have to delve into elisp or you get carpal tunnel... After 20 years of switching back and forth I decided I wanted an extensible editor not a programming language with an editor built in. That's worked well for me. I really always just want the simplest thing that will work as I need to rely on it entirely and understand how it works. If I was to use emacs, I'd probably use mg as shipped wi…

> Until it goes wrong Why? Emacs reports errors fine in my experience and if not it includes a debugger. > or you have to delve into elisp What's the problem with elisp? I guess its a matter of preference, but in my opinion elisp is easier to understand than vim script. Emacs includes extensive(!) documentation for it in it's base distribution. Granted, it's a dated language nowadays, but 3rd party libraries - easily…

>What's the problem with elisp?

So I was trying to make Emacs not drop its stupid temp files next to the opened file and found this piece of incomprehensible code:

    (setq backup-directory-alist
          `((".*" . ,temporary-file-directory)))
While in Vim:

    set backupdir=~/.vim/backups
Oh, and it seems I'm missing line numbers, let's google on how to enable them and found this page http://www.emacswiki.org/emacs/LineNumbers

I still haven't gotten it to work.

Meanwhile in Vim

    set number

Re: Emacs and Vim

#73

I still do not undertand the devotion that people have with these text editors. I prefer Vim however I could see myself using it soley or even half the time. I feel like I know the basic commands and it is fast but with the ease of a sublime text or something similar why do people still use these pieces of software so frequently? (Not a rhetorical question)

Because UNIX shell is the most powerful integrated programming environment for development with any language/technology combination. Instead of your typical menu commands (you are lucky if you have 100 or so commands to do very basic and limited things on a selection that you must build with mouse manually) you literally have tens of thousands of extremely sophisticated commands that can easily be chained together to produce amazing things with very little work.

Vim is just part of that tool chain designed to edit text efficiently. Vim is not so much a text editor as it is a language for manipulating text. Vim has dozens of motion commands to move cursor over chars, words, sentences, paragraphs, code blocks, methods, pages, regex etc. So general form of vim commands is nCm i.e. repeat n times command C to the text cursor moves over with motion command m. So for example w is a command that moves to the next word. d is a delete command. So, dw says delete word. 5dw says delete next 5 words. Let's say you are inside if (.) block and you want to change the if condition. ci( says "change inner bracket text" (i.e. everything inside brackets). This deletes everything inside () and puts you to INSERT mode and let's you type new condition.

This makes Vim extremely predictable and discoverable. You learn a new command say gU (turn to upper case) and you immediately know how to turn to upper case entire word because you know how to move by words with w. gUw turn entire word to upper case. gU) turns entire sentence to upper case, etc.

After a while these things just become part of you, and you become really fast at bending text to your will without even thinking. The fact that you can navigate text/code and get to where you want in matter of milliseconds (faster than it takes you to take the hand off the keyboard and reach for the mouse, shake the mouse to find where the cursor is etc) is amazingly liberating of disruptive context switches.

And then if you add shell integration, it means you can apply advanced filters to your text to do pretty much anything. This gets as esoteric as run filter on regex in lines that match another regex, where regex can be any Perl compatible regular expression. But can also be as simple as reformat code, beautify paragraph, insert current date, listing of directory etc. Then you add code completion, file navigation etc and you have something amazing.

Re: Emacs and Vim

#74
post #70

Whether it's vim or emacs, I've always been amazed how these tools can become an extension of the brain like an instrument whose purpose is to materialize a thought process. Framed that way, the editor wars look like a pianist debating with a violinist of the superiority of their respective instruments to convey human emotion. Watching a seasoned vim or emacs user create, mold, shape, reformat text like it was a piec…

> I think there are some mac-centric UX patterns that I have a hard time giving up.

I can certainly understand that; I'm a relative newcomer to the platform, and while Emacs (of course) continues to behave regarding meta keys in the fashion I've spent a lifetime learning, getting used to Option-arrows for "move to next/previous word", and Command instead of Control for shortcuts, is really bothering me.

(Of course, that's mostly just because forcing the user to cramp her hand up like that, in order to access even the most commonly used keyboard shortcuts, is just a really stupid and un-Apple-like piece of user interaction design, and I've yet to find a good way to fix it.)

Re: Emacs and Vim

#75
post #19

Earlier quoted context omitted.

> Until it goes wrong Why? Emacs reports errors fine in my experience and if not it includes a debugger. > or you have to delve into elisp What's the problem with elisp? I guess its a matter of preference, but in my opinion elisp is easier to understand than vim script. Emacs includes extensive(!) documentation for it in it's base distribution. Granted, it's a dated language nowadays, but 3rd party libraries - easily…

>What's the problem with elisp? So I was trying to make Emacs not drop its stupid temp files next to the opened file and found this piece of incomprehensible code: (setq backup-directory-alist `((".*" . ,temporary-file-directory))) While in Vim: set backupdir=~/.vim/backups Oh, and it seems I'm missing line numbers, let's google on how to enable them and found this page http://www.emacswiki.org/emacs/LineNumbers I st…

Things that look like (a . b) are pairs of things a and b. Enclosing them in brackets, ((a . b)) means making a list, with one element, which is that pair (you need a quote or a backquote before it). (list (cons a b)) is the verbose equivalent. In this case, I think, ".*" is a regular expression matching file names, and temporary-file-directory is the directory for file names that match the regular expression.

This is actually quite nice to customize because you can change little bits of behaviour by just adding another pair (regex . string) to the list. Typing "C-h v backup-directory-alist" also explains what the list is for and lets you customize it with a gui.

Re: Emacs and Vim

#76

I still do not undertand the devotion that people have with these text editors. I prefer Vim however I could see myself using it soley or even half the time. I feel like I know the basic commands and it is fast but with the ease of a sublime text or something similar why do people still use these pieces of software so frequently? (Not a rhetorical question)

Because UNIX shell is the most powerful integrated programming environment for development with any language/technology combination. Instead of your typical menu commands (you are lucky if you have 100 or so commands to do very basic and limited things on a selection that you must build with mouse manually) you literally have tens of thousands of extremely sophisticated commands that can easily be chained together to…

> Because UNIX shell is the most powerful integrated programming environment for development with any language/technology combination.

Only if you never experimented with a Lisp / Smalltalk REPL from the old Xerox PARC environments.

EDIT: Should have mentioned the later Lisp Machines and Oberon (specially System 3) as well.

Re: Emacs and Vim

#79
post #17

Emacs+Evil is the next Vim. And yes, CtrlP is probably the thing you'll miss most. But all the other things I got from switching from Vim to Emacs+Evil easily outweigh the missing CtrlP. Vim was great, until I wanted to customize it heavily. It is simply not made to facilitate things like: child processes, SSH, understanding my code, a visual interface for Git.

I miss CtrlP, but I miss the jump list even more.

Re: Emacs and Vim

#80
post #56

I still do not undertand the devotion that people have with these text editors. I prefer Vim however I could see myself using it soley or even half the time. I feel like I know the basic commands and it is fast but with the ease of a sublime text or something similar why do people still use these pieces of software so frequently? (Not a rhetorical question)

I use vim because it's bindings correspond with my thought process. My thought is: "Let's change the next 2 words", my fingers type c2w (change word). The bindings take quite a while to learn, I started using vi mode in komodo edit, but once I realized that bindings like ci" didn't work I switched over to macvim. I haven't used any other editor since then (4 years ago). The other reason is that I mainly "develop" (ho…

I love this explanation of why you like vim, because it's very honest, and one where I can disagree with your preference while having no problem with your argument.

My brain does not work like vim at all. I do not count words. I do not think about whether I want to change, jump or delete. Therefore, I've never been able to use any vi flavor even semi competently: I can technically work in it, and I have read about all the commands, but I am actually slower in Vim than I'd be in windows Notepad, because it's internals do not 'speak' to me at all.

I had a lot more luck with emacs, because I can ignore anything that even considers those low level operations, and just use it's higher level features, like buffers.

Still, I end up doing better in an IDE, because most of my editing is of code, and an IDE understands the code I am writing far better than emacs or vi could.

Post reply on HN