Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Have you learned / tried to learn Vim? How did you approach it?
21 points by vgel on Oct 18, 2021 | hide | past | favorite | 41 comments
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.



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".


> 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.

Agreed. I think, leaning on my metaphor of natural language, that just like you don't learn how to conjugate every verb form in your first week of Spanish, you don't need to learn every Vim noun or verb right away, but you do want to be learning a system that will make slotting in those new operators natural as you learn them.

> 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.

Yep, this is similar to what I was considering. I like your ideas for problems, so definitely will be using some of those :)

> Ideally, a vim plugin could watch for the basic ways of doing more complicated things

I like this a lot. Not sure if it would fit with the model I'm imagining, but I'll have to think about it more, since it seems quite useful.


This is the best suggestion. I've been using Vim as-needed for 10 years and only recently learned "go-to line #" and "start new line below"


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.


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


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`.


> 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.

Completely agree on rote learning vs learning the actual language of Vim and being able to compose commands fluently.

I guess my feeling on muscle memory is similar to muscle memory in a natural language. If someone was learning English, you wouldn't encourage them to simply memorize phrases from a phrasebook, but it still is important to practice -- it's not possible to hold a long conversation where you need to think about verb conjugations every sentence, to become fluent it needs to become automatic.

In the same way, I'm familiar enough with Vim to know "Oh I want to delete the contents of this string, OK that's delete=d + inner=i + string=' -> di', oh crap it was a double quoted string, ok u+di", uh what was I doing again?" I've struggled with finding a good way to practice Vim to the point where I don't make those kinds of mistakes and don't need to think about the operations, in the same way that when I speak English I don't (usually) think about the verb conjugations.

My thought on this tool would be basically a set of drills of the form "Change this file to look like this", which each force you to compose Vim commands in a certain way. In the same way a Spanish textbook might ask you to translate "I went to the store", "She went to the library", "They went to the soccer game", this would have you drill using these manipulation operators in different combinations and contexts until it became automatic.

I know Vimtutor has a little of this, but from what I remember doing it a few months ago, it focuses mostly on the simple commands that are pretty easy to pick up via analogy from other editors (ok dd is delete line, like ctrl+k in sublime), and doesn't have the repetition aspect (you can just do vimtutor multiple times, but then you don't get variety).


I would put more emphasis on the grammar (operator+motion, use of case for mirroring, etc.) than on the vocabulary… and also avoid both repetition and fixed idioms at all cost.

As for "muscle memory", it is only involved in di" at a very low level: pressing the right key on the keyboard. Deciding to do di" is _not_ "muscle memory".


Agreed. Perhaps intuition is a better term for what I'm thinking of than muscle memory, but I think we're on a similar page :) Thanks for your suggestions!


Great.


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.


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?"


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


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).


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...


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.


The two reasons I still use arrow keys in vim:

1. I've been using the Colemak layout longer than vim, so hjkl is no longer the right-hand home row like it is under QWERTY. 2. My main keyboard at the moment is a Poker ][ and the arrow keys are fn+WASD (or WARS if you're being pedantic about the Colemak layout rather than the printed label on the caps)


I now have arrow keys enabled because there is some menu where I need them sometimes. But disabling them helped me a lot initially. I think it will just take longer to pick it up if you can fall back to arrow keys when you get frustrated. I can only speak for standard QWERTY keyboards but some people default to using the arrow keys in vim and I see that as a huge fuckup that needs to be avoided from the get-go.


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.


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


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.


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.


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


Ooh this looks interesting, thank you. Do you know if it teaches more high-level Vim concepts (like text objects), or just the basic commands like hjkl?


I only briefly played w vim adventures ages ago after I already learned vim and liked it but don't remember how far it goes and am not the OP but:

I wouldn't underestimate how good it is to just get those basic moves and simple commands in muscle memory... frees up your attn to get curious about "I wonder if vim can do X" and then self-study is a breeze


It's much more than `hjkl` text objects included as I remember.

`:stats` and you can see the list of topics covered.


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.


Checked out the link, thanks for that. Will have to dig into their approach more.

Agreed with immersion being important. Ultimately, you can't learn anything without work, but considering how useful tools like Anki have been for me in learning languages, I think there's room for something like that to, as you said, improve on that method :)


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.


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.


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.


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.


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.


> 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.


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).


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.


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.


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.


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.


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.


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

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: