Vim and Emacs: All Quiet Up Front

Among the latests Moravia's compositions holy wars The most legendary of which we are aware is the publisher war. Vi / Vim against Emacs. This is particularly fun because they are both free software with very high capabilities.

This goes back many years. Emacs was developed by Richard Stallman in the 35s, released approximately 1991 years ago. Vi is about the same age, created by Bill Joy. Vim, on the other hand, is somewhat more recent and arises from the need for Bram Moolenar to create a clone of Vi for Amiga in XNUMX.

How retro! Publishers from the stone age, when life was simpler. And we continue to use them because they evolve and adapt to the times. Vim and Emacs use modern interfaces in GTK, they have their own extension languages, package managers; among other things that put them among the editors websites.

What do I use them for?

Let's put a completely hypothetical circumstance. A Gúgol is a mathematical word that defines a one followed by one hundred zeros. How do we write it in a text editor?

The first solution that comes to mind is to type a one and press the 0 key until the column counter sets me to 101, because 101 characters should measure this expression. We're assuming we edit this in a competent text editor, which has a status bar to display these things.

Now, I can think of a simpler solution:

i1 ESC 100a0 ESC

Of course this solution requires Vim, or at least Vi. He command is quite simple, and it is as if we were saying to Vim: Being in normal mode, insert 1 and returns to normal mode. Now insert after the cursor a hundred times 0 and returns to normal mode. Vim will carry out our order without question.

Complexity

This solution sounds extremely complex, and I get it. First, because we are dealing with the concept of a modal editor. But there are cases where it is much more useful than it sounds.

Let's say we have a shopping list. We are going to go to the store and we want to write what we are going to bring. Remember that it is something hypothetical, nobody should take their computer to the store to go for food. Anyway, this is our list:

1 Banana 4 apples 2 kilos of sugar 1 Liter of water

It is a very simple shopping list. But we are going to make some arrangements. First, I think a few more bananas would not be bad. As we like aesthetics, we will change the lowercase in apples to leave her as Banana and we will replace the names of the units with their abbreviations.

So let's get started. Since we want a backup of our original list, we make a copy with 4yy and we paste it below with p. Press Ctrl-a a couple of times to increase the number of bananas and move to the end of the next word with e. We go down to the second line, we do a Fm to get to the word apples and press ~ (AltGr-4 on my keyboard) so that the letter changes to its uppercase version. We make a j to go down to the next line and we appear in the k of kilos with b. We exit the normal mode by typing cw and writing the replacement word for kilos, which will be kg. We press ESC, returning to normal mode and again j to do the same with Liter. Ready. This is what our list looks like now.

3 Bananas 4 Apples 2 kg of sugar 1 L of water

The power

Let's summarize the previous action in this:

4yy G p 2Ctrl-A e Fm ~ jb cw kg ESC jb cw L ESC

I have respected some spaces to make it understandable, but it is not usually done. This order of a robot makes us think a lot about its usefulness. But it sure is faster to do this than to move with the mouse, select, copy, paste, delete and so on.

Editors as long as Vim or Emacs can do things like this because they have been developed for years and with very clear ideas of how to do things.

Learning curves

Yes, they are steep. But that's what initiatives like Cream are for, which provides a completely ready-to-use Vim environment right out of the box without having to struggle with modes and that, and guru-mode, an Emacs extension that - as far as I know - helps beginners.

The guru-mode is part of Emacs Prelude, a collection of extensions what make it easy for you if you want to learn.

Extensions

Since they are more widespread editors than many modern editors and have their own extension languages, you can find color themes, plugins and more. There are such interesting things out there like:

It seems that it is easier (or more pleasant) to program extensions in Emacs Lisp than in VimScript. I mean, it's a functional language interpreted by a kernel made for that, against an imperative language made to configure and extend.

Conclusion

Take a look! It costs you nothing, both are free software distributed for free. They must be in the repositories of all the distributions known to man and can even be found in malefic proprietary systems. There is not much more to ask for.

And finally, if you were surprised why I put an e before Emacs in the title instead of a y, it is because it sounds better to me. Something like / í-macs /. I was able to save myself spelling problems by changing the position, but I really like Vim to do that to it 😀


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   rots87 said

    I only use the nano and only to edit some files 0.0

    1.    anti said

      This is mostly an argument for using them. I see that many people prefer not to try them, and I started to write something to encourage them. That's it.

      (I know it's a weak item)

      1.    Damian rivera said

        It's not lazy at all, emacs and vim are great text editors, I prefer them (vim) instead of an IDE

        regards

        1.    anti said

          Thank you. Now that I think about it, I think I accidentally gave a scoop. The 'distribution' I mention looks like it was just released today.

    2.    KZKG ^ Gaara said

      ahahaha it happens to me the same, with nano I'm left over 😀

  2.   eolander said

    Well, recently I needed to edit a file by telnet in an access-point with dd-wrt and I had to remember vi.

  3.   msx said

    1." there is the publisher war. »
    ERROR!
    Vim is an editor, Emacs is the ready-to-use hadron collider on your computer, you know!

    2. Using Cream (ajjj) or any kind of "helper" for Vim or Emacs is the same as installing Manjaro and pretending that you installed and use Arch - with the possible caveat that a helper doesn't change the essence of Vim or Emacs and Manjaro is Manjaro but not Arch.

    If you really want to rock it with Emacs there are some cool sites:
    http://emacsrocks.com/
    http://www.masteringemacs.org/
    http://batsov.com/prelude/
    http://lisperati.com/casting.html

    1.    anti said

      Emacs is a Lisp interpreter with added features for editing text.
      Cream can be whatever you want, but it's there so that starters don't crash directly into the wall of the modal edit.
      Emacs is somewhat easier at first, because yes, write to the first

  4.   anubis said

    [falmewar mode ON]

    Emacs, that operating system that 35 years later still lacks a good text editor 😛

  5.   xykyz said

    "Vim and Emacs". That "e" in the title (and somewhere in the text) is misused ...

    1.    xykyz said

      And by the way, I use vim for everything already. I started using it last year and now it has become indispensable for me. It also has the advantage that vi is pre-installed in all (or at least almost all), which is almost the same in handling, so knowing how to use it you can edit files in any distribution, whether it has X11 or not.

      I have tried Emacs, but they seemed uncomfortable keyboard combinations so I focused on Vim

    2.    anti said

      He already explained it to the bottom. For me what should be used e because the phrase sounds like / vim and i-macs /, observing that the y changes to e when the next word begins with the i sound.
      However, it was much more elegant to put it backwards and avoid problems, but a little experimentation does not hurt anyone.

      1.    xykyz said

        Okay, I didn't get to read the entire article due to lack of time haha.

        It's still a misspelling anyway, as much as it sounds better.

        1.    anti said

          It's okay. Nothing more than this strange thing to criticize without finishing the reading.
          I hope you can excuse me for this lack. It seems that in the review they passed it too, so they have to agree with me, but some reference from the RAE for foreign words should be reviewed. These are not translatable.

          1.    xykyz said

            Yes, I didn't finish it, I admit the mistake, but I don't have time lately and I can't be around as much as I would like. In fact, it is extremely strange that in the end I could have been here for a couple of moments today.

            As for foreign words, the conjunction 'and' is not a foreign word, even though emacs is. From what I understand (which I also don't have time to verify now) emacs should read emacs, no matter how much we read it in English. Otherwise it would be difficult to apply the rules of spelling, because if you speak Spanish you don't have to speak English or German, and therefore you don't have to know how those words are pronounced in those languages.

            Anyway, it was not a criticism, just a comment and I tell you from now that I always like your articles 😉

        2.    anti said

          Thank you. Feedback and constructive criticism serve us all.

  6.   diazepam said

    I don't like to use them but, in an Advanced Functional Programming course, you had to make a Vim-type editor, but in haskell.

  7.   Tyo100 said

    I prefer vi or vim because it is the most universal since it works the same in any OS and all * nix include it and by all I mean everyone from GNU / Linux, HP-UX, Solaris, AIX, BSD to shortened versions of Linux as dd-wrt.

  8.   Abimael martell said

    I program 100% with VIM (Ruby, PHP, Javascript, Coffescript, CSS, and more)
    here is a distribution for ruby ​​programmers, it is very complete and has many useful things, greetings (https://github.com/carlhuda/janus)

    1.    Damian rivera said

      It is what I say (above) I use vim for mono, java, perl, bash and python only that the non-interpreted languages ​​we have to make use of the terminal to compile, in FreeBSD I use (and use) a lot of VI which is the editor native but also install ee and joe very good (similar to nano), in Gentoo the good thing is that it brings nano but I already compiled vim and I like it a lot! It is the best editor there is and modified to your needs it is a perfect tool for system administration

      regards

  9.   Matias (@ W4t145) said

    Vim Vim Vim !, forever, it works for everything and anywhere, I never change it

  10.   dwarf said

    Ahm, I don't know, I'm lazy and I use Sublime xD

  11.   Daniel Rojas said

    I always use Vim, I love it and I find it very practical and comfortable 😀

  12.   dragnell said

    Simply vim, essential in my day to day.

  13.   Guido rolon said

    vim RULES! but «ed» ROCKS !!!!,

  14.   vim said

    Vim orange writes fine vim cristal writes normal, vim, vim, vim ...

  15.   yoghurtwhite said

    You should learn the differences between "because", "why", "why" and "why". Male, in all the text you have not given a single one.