HACKER Q&A
📣 vgel

Have you learned / tried to learn Vim? How did you approach it?


I've been brainstorming some ideas for a tool or service to help people learn and get faster at Vim, and was curious what HNers have done to learn Vim. Of course there's Vimtutor, and Vimcasts, but I'm especially interested in how people have overcome the "practice hump" where Vim initially slows you down due to a lack of muscle memory.


  👤 godshatter Accepted Answer ✓
I would suggest that people new to vim not trying to learn all of vim quickly. I think they are better off learning enough just to get by at first. Just the basics. Then learn a new key sequence that solves an immediate problem, understand what it's doing and why it works, and add it to their set of tools they use daily. Muscle memory, like you said. They should keep adding them as they need them, and keep using the new ones they've acquired whenever the need for it comes up. When I started learning vi, the learning curve was very steep just to get the very basics down. It wasn't until I learned a few commands out of sheer frustration that I realized how powerful it was. Diving into that was too much, though, so I started learning small bits here and there and internalizing them. That concept has worked well for me in the 25-ish years I've been using vi or (later) vim.

So I would suggest maybe a curated list of problems that need to be solved and their vim solutions, with a method of searching for them when needed and a way of suggesting one of those problems/solutions every so often. Kind of like a daily/weekly helpful tip that gives them out in order of complexity. These would be things like how to swap two lines, keyword search and replace, how to insert something at the start of a set of lines, how to join lines, how to use buffers, etc. Ideally, a vim plugin could watch for the basic ways of doing more complicated things, like someone deleting the same number of characters one at a time on each line, repeatedly, and let them know about repeat counts, or seeing someone deleting characters one at a time stopping at a space and typing new text in multiple times and let them know about "ce".


👤 meitham
I couldn't recommend http://vimcasts.org/ enough. It's short and really well made, and fit within mobile screens. I wish there was something similar for Emacs!

I started learning Vim 2009 when an older and much more experienced colleague of mine was making funny comments about me using Notepad++. "Get a real text editor" he was saying. At the time, I never really thought about the need of learning a new text editor, specially one as old as Vim. Though to impress this colleague I decided to learn Vim, and demonstrate powerful Vim tricks that my colleague didn't know. This carried on into an obsession with Vim. Drew Neil, the author of Practical Vim book, and the maker of the Vimcasts, used to run a Vim Dojo in London circa 2013, and I found that to be a great source of learning Vimscripts and writing tests with Vim.

This could be hard to explain, but the more I learned Emacs the more I found better ways of doing the same Emacy thing in Vim.


👤 SuboptimalEng
Kenneth Cassel built a Vim tutor[0] that went viral on Hackernews a few months ago[1]. It is an interactive course that costs $25. He ended up making more than $10k the month he released it and got into YC afterwards!

Inspired by him, I made a 20 minute React JS tutorial[2] going over how to build a web app that teaches you Vim.

[0] https://www.vim.so

[1] https://news.ycombinator.com/item?id=25846347

[2] https://www.youtube.com/watch?v=BwTI9RT0q-A


👤 johncoltrane
First, your question.

I was on the market for a TextMate replacement that worked both on Mac OS X (at work) and Linux (at home) so I searched far and wide and came up with a list of editors and IDEs, GUI and TUI. I approached all of them with the same strategy:

1. follow the introductory tutorials, if any,

2. if the first contact was promising, use it for a while, learning and configuring as I go,

3. move to the next editor/IDE in the list.

For some, I gave up after half an hour, for others it went on for a few weeks, but I wanted to give all of them a fair chance so I eventually ended up at the bottom of the list, with Vim and its weirdo reputation.

So I did `$ vimtutor` and I was instantly hooked. As instructed, I graduated to the user manual which I stupidly rushed only to fall into the blogosphere trap and its many "here is my setup" posts. The winner was clear at that point and, after wasting a couple months trying to shoehorn my TextMate workflow, I finally decided to throw my `.vim` through the window and learn Vim properly this time, with the user manual.

Two months after that I was finally able to replace TextMate with Vim and I have never looked back.

Second, thoughts on learning Vim.

- Random online snippets, quick tips and tricks, tweets, etc. are useless because they lack context. They are also wrong very often.

- Using it right away for work is a bad idea because it forces you to copy other people's config and install lots of plugins that hide Vim and ultimately prevent you from learning it properly.

- Learning/using Vim has nothing to do with muscle memory. This is a common misconception that leads to rote learning and, since Vim has hundreds of commands, the use of flawed ready-made cheatsheets _and_ the looking for ways to bypass that horrifying learning curve.

- A flight simulator is not a plane and a tool-for-learning-vim-that-is-not-vim is not Vim. There are very good reasons for doing part of one's learning on a flight simulator but learning Vim in Vim is as free and safe as it gets so there is no point learning it via a third party tool.

Third, thoughts on your project.

There is no _need_ for anything else than `$ vimtutor` and `:help user-manual`.


👤 karmakaze
When people say 'learn Vim', are they talking about the core editing and commands, or the I'm'proved parts that make it Vim (over vi)?

To learn 'vi' I had an 8.5 x 11 tri-fold cheetsheet that I printed out, pinned to the wall of my cubicle (yeah, it was a while ago) and referred to in constantly. Even when I wasn't editing, I'd take it down and browse up and down the columns to see what I knew/used that I hadn't before and recognize more stuff that made sense now when I had to memorize it without reason. Eventually you see how all the patterns fit together and how small it all is, wondering how you couldn't see it all from the start.

As for the muscle memory. Just get over the hump. Another pro tip. If you were thinking about using a custom keyboard layout, sort that out, because vi(m) muscle memory has nothing to do with alphabetic letters. It would be more like a musical instrument with the scale keys shuffled nonsensically. Sadly I had shooting pains up the backs of my hands, switched layouts and typing words is back but my vim's still slow, rebuilding muscle memory, so I'm with you on that.


👤 cratermoon
Years ago, and it was still just 'vi', and the only editor available on the flavor of Unix I was using at the time. I just learned what I needed to know by reading the available manual pages. I started with "how do I run it?", "what is this 'mode' thing?", "how do I save and exit?" "how do I move around the file I'm editing?"

👤 drekipus
Started with how to save and exit. As well as insert mode.

Then used it like glorified notepad for ages, eventually finding little hacks like "oh, O will put me on insert mode on the line above"

The starting the grammar, diw, etc


👤 miccah
Immersion. The fastest way to get through the "practice hump" is to accept the dip in productivity and keep learning. No turning back to your old method. The same applied when I learned the Dvorak keyboard layout, and I presume the same applies for language learning among other examples.

For vim specifically, I think mode changes are the most important to learn first. Past that, it's building muscle memory for all the keybinds (and actually discovering the keybinds).


👤 cardz
Like others have mentioned, immersion was a key factor. I also read from Practical Vim by Drew Neil[0] every day and created a bunch of type in the answer and cloze deletion Anki cards with the different commands. [0] https://pragprog.com/titles/dnvim2/practical-vim-second-edit...

👤 dokem
If you code full time just force yourself to use it. Disable arrow keys in the .vimrc. Find the most common 5 procedures you use in your current editor and write out how to do those in vim on a post it note under your monitor. Also print out the vim cheat-sheet and have it visible. You'll pick it up in a few days. No one is going to care that your productivity dropped for a week.

👤 smackeyacky
Hmmm. 1986 I think it was.

boss: "You need to learn vi" Me: "Why, this Sun has a text editor on it" Boss: "We own more than Sun workstations, go do this job on the Pyramid" Me: "rsh...ok I'm in. Ok. Uh, how does vi work?"

Not sure it's a real necessity these days when Nano exists but vi or its modern equivalent is on OSX, all(?) Linux distributions and generally shows up in WSL on Windows.

The Vim mode in VSCode is...OK I guess but you do need to be a bit careful with cut and paste, as the paste menu item doesn't necessarily give a hoot about the Vim mode you're in and stuffs things wherever you right clicked rather than where the need the text to go.


👤 auslegung
I followed this plan, and have recommended it many times https://peterxjang.com/blog/how-to-learn-vim-a-four-week-pla...

👤 brhsagain
I guess I have the opposite advice. You literally just use it. It takes about two weeks to get back to your old speed, and then after that everything becomes an additional superpower.

I started using vim because in high school a guy I respected at the time started using it, and I wanted to look like a cool hacker or something, so I used it for my programming class assignments.

But yeah, you just have to use it. You should generally structure your life so that you can commit to the expense of learning something new for two weeks.

Edit: oops, I just read that you’re asking in the context of helping other people learn. Still, my advice for getting over the hump is to get over the hump, one keystroke at a time.


👤 softwaredoug
Vim was the best “dumb” editor over an ssh connection. It grew over 15 years into the primary way I write most code.

One never really learns “vim” TBH. Over the years I periodically take a dip in productivity to learn a knew thing and customize my experience. Some things are firmly in my muscle memory. But many things will never make it in there.

That’s the nature of the problem. Vim wants you to take a high level of ownership over the parts you want to emphasize. It’s hard to teach that.

Some people will get great value as a “dumb editor that works over ssh” while others have gone very deep into obscure corners to memorize whatever arcana helps them. All are valid ways to vim IMO.


👤 oolfreak
Have you tried Vim Adventures - helped me a lot :)

👤 Syntonicles
About 15 years ago I got a job in IT with lots of ssh hops and server work. I approached it the same way I approached the Linux terminal. I made a rule that everything I typed from thereon out would be in Vi.

Recently I did the same with Emacs. I'm a big fan of learning through complete immersion.

My opinion is that my method is horrendously inefficient and arduous. There's a lot of room for deliberate practice.

Here's one: https://www.shortcutfoo.com/app/dojos/vim/learn

If you can improve on that method please do.


👤 zwieback
Like many others I learned vi when realistically emacs was the only other alternative on UNIX workstations.

What really helped me were my coworkers who already knew vi and showed me a few tricks. Like using "." for repetitive tasks.

I think some example scenarios would be helpful. I rarely use vi these days but I have a soft spot for retro technologies so I think specifically pointing out a few of vi's strong points and contrasting them with the way most editors handle it would be good.

Mouse-free navigation with a few keys and little wrist movement is another strong point so maybe show a few animations how to make the most of that.


👤 ducharmdev
I went through vimtutor multiple times, until the basics stuck enough to allow me to (mostly) work without constantly looking at a cheat sheet.

I used the VSCode vim extension too, which I believe eased me into it since I was already comfortable with VSCode.

I know the extensions are limited compared to straight vim, but IMO at a certain point you get diminishing returns with time spent learning your tools. Personally for me, getting proficient in normal, insert & visual mode was most worth it; I'm sure I'd benefit from learning how to do crazy macros, but didn't see a need to go beyond that.


👤 atsaloli
I put together a course on Vi basics that's been very well received at conferences and that I throw in for free at the start of my week-long Linux system administration Configuration Management training (if the client wants it).

I based it on the paper "An Introduction to Display Editing with Vi" by Bill Joy and Mark Horton http://www.verticalsysadmin.com/vi/vi_editor__bill_joy.pdf

Bill Joy is the author of Vi.


👤 bravetraveler
I wouldn't say I've learned it, but I have learned some useful tricks - enough to say it was worthwhile.

It's really as simple as using it. Both vim and i3 seemed insurmountable at first, but after I dove in; I realized things weren't so scary.

Doing things and thinking about it is practice, with that comes muscle memory.

You can honestly get to the point of unconsciously doing a series of events across applications/files. Just don't try too hard, it comes with time.


👤 yellow_lead
I learned a few things - navigating, words, creating macros, searching. As needed, I searched for how to do X, found vimwiki, and tried to commit it to memory. I learned the most used things this way. Creating macros was the most useful to me. I can do an operation on megs or gigs of a CSV that I may not even be able to open in something like Excel.

👤 Const-me
> how people have overcome the "practice hump" where Vim initially slows you down

I have not. I install and use nano https://www.nano-editor.org/ and/or using Far Manager SCP client with the built-in editor.


👤 gauchojs
I'm pretty skilled and love the modal mindset - but still feel like I'm faster with Vscode, with less effort.

You can do so much with multiple cursors and a few extensions (expand selection to bracket, insert numbers, and align cursors are the operations I use the most).


👤 echlebek
I've been using vim for 10 years now. I learned it by working with other vim users 1:1, and harassing them to teach me things. It worked pretty well. Eventually I cribbed their dotfiles and started maintaining my own.

👤 mooreds
Added 'set -o vi' in my .bashrc.

That's it. When you do this, you now need to use vim commands to move around the shell.

It's a great way to force learning/reinforce your muscle memory of vim commands.


👤 kingkongjaffa
I use spacemacs with eVIl mode, the vim bindings are useful. I quite like a modal editor for medium term work where I have to review, browse, and then edit. Switching modes brings a clarity in thought.

👤 vonadz
Just spend a week using it for your everyday work, and disable arrow keys. It really sucks for that week, but after I felt fluent to the point where it was no longer hindering me.

👤 omgmajk
I learned vi in a time where there were not much else... ed maybe but that's not very good. I went about it by reading man-pages as dial-up was expensive.

👤 high_byte
I don't use Vim but I do love Vimium!

although I mostly use the one feature - F to select link.