2020-08-09-what-is-this-vim-talk-all-about.md (6515B) - raw


      1 <!-- title: What is this vim talk all about? -->
      2 <!-- slug: what-is-this-vim-talk-all-about -->
      3 <!-- categories: FOSS, Miscellany -->
      4 <!-- date: 2020-08-09T15:16:00Z -->
      5 
      6 Oh no! Another [vim][vim] post! Well... yes. I have seen a lot of people
      7 criticizing vim before even trying it, so I am going to try and explain my
      8 history with it and what I like about it. If you aren't aware, vim is a text
      9 editor that is normally used from the command line (and, normally, the mouse
     10 doesn't work in it or is deactivated).
     11 
     12 ## Getting into vim
     13 
     14 When I first saw people that got around a computer with the keyboard, I realized
     15 how much faster you can do stuff when you don't use your mouse. By that time, I
     16 used the copy/cut/paste shortcuts and that was pretty much it, I didn't even use
     17 `Alt`+`Tab` to change between windows, so I was mindblown when I saw people
     18 moving around so quickly without touching the mouse. For me, the keyboard was
     19 simply a tool to write text.
     20 
     21 Although I realized that being more familiar with the keyboard would make me
     22 more efficient, it was hard to get used to it. I had to think before every
     23 keystroke, and everything was very slow. GNU/Linux helped a lot with getting
     24 more used to the keyboard, not only did I use a couple more shortcuts, but I
     25 also found myself using the terminal often.
     26 
     27 At some point, a friend introduced me to vim. I remember[^memory] seeing such a
     28 weird program—and in the terminal!—and thinking: why would anyone use that?! I
     29 was told that there were a lot of shortcuts, and experienced programmers could
     30 move through a file very quickly with it, as well as do complex operations with
     31 the file contents. I believed it, but I didn't want to spend years mastering
     32 vim, so I kept going with a simpler text editor. A couple of months later, I had
     33 a programming class where the teacher would sometimes show us his screen while
     34 writing solutions to exercises. He was fast, very fast. He moved around the file
     35 very quickly and the craziest part was that he was using Geany. All that speed
     36 was reached with `Home`, `End`, arrow keys, etc. No *real* shortcuts. I think
     37 that is the point in time when I understood what a program focused on keyboard
     38 shortcuts (like vim) had to offer.
     39 
     40 [^memory]: This is how I remember it, but it was—I think—three years ago, so it
     41   might not be completely accurate.
     42 
     43 Since then, I have tried vim many times and, truth be told, it is hard to start
     44 with. I also didn't code a lot during certain times, and when I had to, I just
     45 wanted to get stuff done, so finding times to figure out vim wasn't as easy.
     46 Another friend recommended using vim when editing Latex files because of a
     47 plugin. I was creating Latex documents for some classes so I used vim for a
     48 while to edit those files[^tex]. This is how I started to be able to do some
     49 things in vim. I eventually started managing servers and used it more and
     50 finally, at the start of the confinement, I decided to use it exclusively. It
     51 took some time adjusting to it, but I haven't opened any other editor except for
     52 a couple of occasions.
     53 
     54 [^tex]: The plugin is really nice (especially when writing big amounts of text),
     55   but I was so uncomfortable with vim that I would write everything in vim and
     56   then edit/review it with a different editor.
     57 
     58 ## What I like about vim
     59 
     60 The first thing that I like is that it is a modal editor, meaning it has modes:
     61 you are always on one mode, and the editor responds differently to keypresses
     62 depending on the mode. The two most basic modes are normal and insert. Insert
     63 mode responds to keypresses like you would expect from a text editor: if you
     64 press `x`, an `x` is appended to the file you are editing, and so on. Normal
     65 mode, however, will not print the letter you just typed. For instance, if you
     66 press `x` the letter under the cursor will be deleted, and if you press `w` the
     67 cursor will move to the first character of the next word. This is great because
     68 there are a lot of shortcuts on normal mode that are incredibly useful, and let
     69 you move around the document without the need of leaving the [home row][hr] or
     70 pressing modifier keys.
     71 
     72 Now, normal mode has a ridiculous amount of shortcuts, each key has some
     73 behavior assigned to it, so it can be hard to learn it all. In the end, it is
     74 only a matter of practice and it is easier than it looks like. On top of that,
     75 these shortcuts act like a language, which makes them really powerful. With
     76 that, I mean that shortcuts can be mixed to create new shortcuts. It is hard to
     77 explain and there are a lot of explanations online, so I will refer you to two
     78 sources, and you can keep investigating if you are interested:
     79 
     80 - [Your problem with Vim is that you don't grok vi][so]: A very detailed Stack
     81   Overflow answer.
     82 - [Mastering the Vim Language][yt]: A YouTube video of a talk in the Boston Vim
     83   Meetup of 2015 by Chris Toomey.
     84 
     85 This is it for me. The fact that you can do so many things with the keyboard
     86 without the need to keep `Ctrl` or `Alt` pressed and do them in such a natural
     87 "language" is what makes vim the best editor I have tried so far. Of course, you
     88 can make other editors behave like vim ([vi][vi] really), but vim is the best
     89 one I've tried. Well... I actually use [neovim][nv], but for my use-case, I
     90 probably wouldn't be able to tell them apart.
     91 
     92 ## Final comments
     93 
     94 There are still a lot of things left for me to learn about vim, especially when
     95 dealing with a project with lots of files, but I am now more comfortable with
     96 vim than with a normal editor where you move around using the mouse.
     97 
     98 As you can see from this post, what I appreciate the most of vim is how it
     99 behaves, so I could easily change to another editor that would copy this
    100 behavior and add other features. It is useful that it is run on the terminal, as
    101 it is normally how I move around the computer, but I don't have anything against
    102 other editors. I also want to try [Emacs][emacs] again at some point (with [Evil
    103 mode][em], of course), we'll see how that goes!
    104 
    105 
    106 [vim]: <https://www.vim.org/> "Vim"
    107 [hr]: <https://en.wikipedia.org/wiki/Home_row> "Home row — Wikipedia"
    108 [so]: <https://stackoverflow.com/a/1220118> "What is your most productive shortcut with Vim? — Stack Overflow"
    109 [yt]: <https://www.youtube.com/watch?v=wlR5gYd6um0> "Mastering the Vim Language — Youtube"
    110 [vi]: <https://en.wikipedia.org/wiki/Vi> "Vi — Wikipedia"
    111 [nv]: <https://neovim.io/> "Neovim"
    112 [emacs]: <https://www.gnu.org/software/emacs/> "Emacs"
    113 [em]: <https://www.emacswiki.org/emacs/Evil> "Evil mode — EmacsWiki"