Live data from Hacker News

Emacs and Vim

martinklepsch.org

231–240 of 277 posts

Re: Emacs and Vim

#231

So when i'm programming I find myself spending far more time thinking about what to type next than actually typing it, seems to me like there isn't much to gain by learning vim/emacs or am I missing something?

Doesn't that argument work just as well for touch typing? Would you argue that being a touch typist is useless?

Do you ever use keyboard shortcuts... Ctrl-A, Ctrl-F, Ctrl-C, Ctrl-V, Ctrl-Z, Shift-End, etc.? Extrapolate that to everything you might want to do when reading, reviewing, or editing a text file.

Re: Emacs and Vim

#232

So when i'm programming I find myself spending far more time thinking about what to type next than actually typing it, seems to me like there isn't much to gain by learning vim/emacs or am I missing something?

People often mistake the succinctness of vim's commands as an attempt to save a few keystrokes typing, but that's only a side benefit.

The vim command structure makes it trivial to define transformations on common blocks of text; words, sentences, paragraphs (lines), blocks of code inside {..}, etc. It makes it easy to repeat those commands, by repeating them a fixed number of times, applying them to every instance in the file, or asking for confirmation around each one.

But, most importantly, it means that we can now extract that little bit of text-transforming functionality into a script we can save and bind to a new command (if it's something particularly reusable). This is really what vim is about to me - providing a language to describe text transformations, in the form of sequences of commands. This means that the way I code every day, conveniently saving me a few seconds like you mentioned above, is the same method I use when writing/editing plugins/macros for the editor to do more complicated tasks, like say consistently formatting every line of a log file that begins with [ERROR] and removing all other lines, so we can process it with some other tool.

Sure, you could write a script in [python/perl/ruby/etcetcetc] to do all that just as well, but the point is that Vim provides a nice little domain specific language right at your fingertips, optimized for working with text at a higher level, capable of handling one-off jobs as easily as big jobs over a whole log file or even as a little command to be reused later.

Re: Emacs and Vim

#233

So when i'm programming I find myself spending far more time thinking about what to type next than actually typing it, seems to me like there isn't much to gain by learning vim/emacs or am I missing something?

A lot of it can also come down to pure fun. I really enjoy programming in vim, and I had fun learning a new tool.

It's not always about pure efficiency metrics. I code better when I enjoy using my tools.

Re: Emacs and Vim

#234
post #16

Earlier quoted context omitted.

I use C-{n,p,f,b} all the time, though admittedly their placement is more convenient with Dvorak. Though I also tend to use M-f and M-b a lot to navigate by words instead of characters. I also often navigate by incremental search.

Speaking of incremental search: try ace-jump-mode, it's really good. Here is a video that shows it at work: http://emacsrocks.com/e10.html

How long did it take you to get used to that? Replacing the searched-for letter with (essentially) a marker seems a bit mind-altering.

Re: Emacs and Vim

#235
post #86

Earlier quoted context omitted.

Another common one is Capslock.

Mapping capslock to be esc is what made vim possible for me.

Agreed. I don't know how anybody could use vi with escape unmapped. It's also very useful outside vi though, since esc is the default 'cancel' key in many cases. For example, most browser dialogs (and keyboard-navigable menus) can be closed with esc, and it works for many desktop dialogs too (at least on Linux).

Re: Emacs and Vim

#236
I'm both a vim and emacs user. I love vim for all the reasons everyone always mentions, but emacs comes out ahead consistently basically because emacs-lisp is so much more usable to me than vimscript. I find it much easier to create or modify plugins in emacs... Don't like the (often overfeatureful) functionality of a plugin? Change it!

Re: Emacs and Vim

#237

So when i'm programming I find myself spending far more time thinking about what to type next than actually typing it, seems to me like there isn't much to gain by learning vim/emacs or am I missing something?

You are thinking about "what to type". In an editor with a rich set of text editing commands, what you can type is expanded. So when you are thinking about it, what you can think is expanded.

Re: Emacs and Vim

#238
post #129
post #9

Earlier quoted context omitted.

Usually the strong defenders of emacs tell you that you must use c-n c-p c-b c-f to move because those are better and you will adapt in a short time. Then the strongest defenders of emacs tell you that you must use whatever you want because the purpose of emacs is that the editor must adapt to you and not the opposite.

Actually I think the strongest defenders of emacs say you use C-s and the like for most navigation. Moving character-by-character is slow and inefficient, so the argument about whether C-n C-p etc. are better or worse than hjkl is irrelevant. I have my own code editor which is more like vi than emacs, but I'm using interactive search in it.

Yes! C-s navigation, once learned, is the thing I miss most from other editors.

Re: Emacs and Vim

#239

Earlier quoted context omitted.

Craftsmen and tools. It is an age old story, you grow to trust and understand a tool. Programmers and text editors are an extreme example, because programmers often spend 30+ hours a week using a single too, their editor. Vim and Emacs have survived because they are "fit for a purpose"... they are really good at editing text! Emacs has a niche in expandability. You can always twist Emacs to do your bidding... and it…

>Vim has much more of a culture of users, people who want to edit text rather that toy with their editor. I don’t know about that. I really got into Vim because it’s so customizable. The number of general purpose and very specific plugins is pretty amazing. And the Vim Awesome site that tracks plugins is pretty damn awesome: http://vimawesome.com

Vim has great plugins -- but expanding it is often best left to experts. I have a pet theory that part of the reason for the high quality of many vim plugins is the horrors of writing them (and of course, tpope). Most Vim users are simple, "off the shelf" users -- they use plugins, but they don't WRITE plugins and they often don't radically change the environment (it still feels like vim, as expected). Vim is a good editor that works great with other tools.

Emacs is more -- of its own things -- lots of people write little bits of elisp to do their bidding, and the "plugins" can completely reshape the editor into an IRC client... a mail client... a media player ... a connection to spotify ... etc. It is a wild crazy world powered by elisp.

Re: Emacs and Vim

#240

Earlier quoted context omitted.

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…

So where would you suggest going to learn all of this seemingly endless amount of information?

Don't aim to learn everything. Learn to be productive and get to the point where you do things you do fast enough. Vim itself has enormous amount of functionality, so it is useful to read vim reference manual. It comes with one and you can get one in PDF as well here:

ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf

Also read entire exhaustive help at least once so you get the idea of what is available (it can be done in one weekend, don't try to memorize too much just familiarize yourself with content, then later when you wonder how would you do that in Vim you will remember you read something about that once).

Vim has really great indexed help that you can access directly:

:h :h index :h

and there is also grep for help to search entire help for matches

:helpgrep

No matter what you do understand that you will get slower before you get faster. At first expect your productivity to go down seriously, because everything will be strange and new. But persist with it and force yourself to use it. Once you get to the nicer bits you probably will not want to go back. After 6 months of regular use, you will not be able to back, every other editor will feel dumb and will frustrate you to no end (be careful when typing email: ESC key dismisses the compose dialog in a lot of email programs without asking you anything :D).

As for UNIX shell and tools, again get a good BASH tutorial book and learn the basics of interactive shell, learn how to do loops, globs etc. The rest is then all about learning individual tools, not shell itself, which is rather small command interpreter. Look in your /usr/bin and /usr/local/bin for commands and read their man pages. Experiment a lot with them and look at examples of creative use of these.

Back in the early 90s I had a year long course in vi (not Vim) but started using Vim on Amiga 500 days, and after 20 years I still come across new commands and ways to do things. This is the beauty of Vim, you grow with it and it never stops to amaze you. But it is a skill that you keep for a lifetime. It's like learning to touch type, you do it once and you type efficiently for the rest of your life. You may get faster or slower at times in your life but you are always faster than hunt and peckers. Same with Vim, dumb editors come and go, but none ever approach the completeness of Vim.

Post reply on HN