
Two Simple Steps Helped Me Learn Vim - delongshot
http://adamdelong.com/two-simple-steps-helped-me-learn-vim/
======
muraiki
The biggest thing that helped me to learn to use vim fluently by building up
muscle memory (and making commands automatic) was playing Vim Adventures, a
browser based adventure game that gradually teaches you vim commands:
[http://vim-adventures.com/](http://vim-adventures.com/)

I haven't tried the full (paid) version yet, but the demo was enough to get me
moving around text quickly. Now I finally understand why people use this crazy
thing. :)

Also, if you really want to fly through text, try out
[https://github.com/Lokaltog/vim-easymotion](https://github.com/Lokaltog/vim-
easymotion)

~~~
hereonbusiness
The biggest thing that helped me was when I realized that it actually all
makes sense.

Every time you use vim and catch yourself repeating a command over and over
(x, dd, hjkl) take a moment and think about if there is a more efficient way
to do it by combining the commands you know.

Let's say you need to delete everything from you current cursor position to
the next paren in the current line, ok you know that:

t -> move till char x in the current line

T -> move till previous char x in the current line

d -> delete

so you can combine that to:

dt( -> delete everything till next ( in line

Delete 10 lines, instead of 10 times "dd" you can just do: 10dd

Go from line 0 to line 20, instead of pressing j 20 times: 20G

Delete from current position to line 20: d20G

These are all really simple examples, but once you get the hang of it you move
on to more complex stuff in no time, and you probably won't even have to look
it up, it will just make sense.

~~~
muraiki
Yes, but there's a difference between "makes sense" and "I can do it without
thinking, so it is a lot faster than pressing ctrl + right arrow a few times"
which then leads to "maybe I'll use vim instead of Sublime Text after all." :)

~~~
hereonbusiness
Everything takes time to master, but understanding/being able to make sense of
something makes a big difference.

You just started learning vim and are moving around with hjkl and x-ing words
letter by letter, then you learn about moving with w/W and b/B and
repeating/combining commands (2w, 2b, ...), and the next time you're using it
you think "wait a minute, _d_ is delete, I use _dd_ all the time, why wouldn't
I just _d2w_ to delete those 2 words, huh, it didn't work right, the cursor is
in the middle of the first word, I have to _bd2w_ ", at least that's somewhat
how I first started getting it. Once you understand something it's hard to
forget and after a short time using it you don't really need think about it
like you mentioned.

------
MrBuddyCasino
Time and again, these "how to coerce yourself into learning this hostile tool
called vim" posts appear. I read them, and it sparks my interest.

But usually, whats missing is part 2, which goes: "... and this is why it was
so totally worth it". An no, just because it works over SSH and is installed
on every server is not quite sufficient.

Also, are you programming in a script language or a .NET or JVM behemoth?

~~~
jpradeek
For me, I was always annoyed with how tedious it was to edit things. i.e, The
gap between what I think vs what I have to do in the editor to get it done.
This constant annoyance was what drove me to spend time and energy into
learning it. I believe that if you don't care about it, you won't really
benefit out of it. Because the whole point of switching to Vim/Emacs is to
minimise the gap between what you think and how you do it.

Let me give you an example. You'll be thinking, "I need to change all the
arguments to a function." In other editors, you'll press the arrow keys until
you get to one end, press backspace key multiple times until you get to the
other end. In Vim, I'd do "ci(" which means "change everything inside (" \-
which is pretty much how I think about what I need to do. A similar but more
common example is changing text inside quotes. Again, that'd be 'ci"'.

Not everyone feels the annoyance about this and if you don'tt, hats totally
fine. Learning something just because its cool is never worth it. Learn it if
you really care about it.

Also read this post by Yehuda Katz about how he started for some ideas.
[http://yehudakatz.com/2010/07/29/everyone-who-tried-to-
convi...](http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-
to-use-vim-was-wrong/)

~~~
Someone1234
Your example falls flat. Any text editor with regular expression support can
do that...

Do you have another example?

~~~
Hello71
vim:

step 1: type ci(. step 2: type what you want to replace with. step 3: press
ESC.

notepad++:

step 1: press Ctrl-H. step 2: type \\([^)]*\\). step 3: press tab. step 4:
press (. step 5: type what you want to replace with. step 6: press ). step 7:
move hand to mouse. step 8: move cursor to and click on "Regular expression".
step 9: press enter.

Do you have another example?

~~~
therealunreal
Not implying that the vim way isn't faster but on any regular text editor you
can:

ctrl+right arrow once or twice, right arrow to skip the (, shift+end,
shift+left arrow, then type.

------
wyclif
A more elegant solution than a notecard may be using a vim cheatsheet
wallpaper, like this:

[http://vimfoo.com/2012/09/vim-shortcut-
wallpaper/](http://vimfoo.com/2012/09/vim-shortcut-wallpaper/)

The downside of that is that it isn't customizable, so I get why he likes the
3x5 card. But at least you can't lose this.

~~~
to3m
"Awesome! With my vim cheat sheet wallpaper I will never forget _anything_!
This time next year, Rodney..."

<opens large vim window>

"Oh..."

~~~
Zardoz84
Konsole with transparent background or set the wallpaper as background...

------
alfiedotwtf
Here are some more tips:

    
    
      - disable arrow keys
      - turn relative numbers on by default
      - force yourself to only move vertically using relative numbers
      - force yourself to only move horizontally using [fF,;]

~~~
madeofpalk
Why would you want to disable arrow keys?

~~~
beaumartinez
To to keep your fingers on the home row, in order to have better access to all
the other keys in your keyboard.

Having your fingers on the arrow keys mean your hand has to travel that much
further to type the other keys—making you slower.

~~~
AlexeyBrin
I've always wondered if the "disable the arrow key" advice given to every VIM
novice makes any sense for the user of a 11" \- 13" laptop. It was probably a
good advice for a classical keyboard, but I find the arrow keys quite handy
when I work on a small laptop keyboard.

~~~
Morgawr
I started seriously using vim around the time I started coding on the go with
a very old eeePC (the first model, the absurdly small one). This was around
5-6 years ago probably. Back then I had already used vim before but only as a
"normal" text editor, just go into insert mode and move around with arrows.

I was forced to use vim because that old piece of crap PC (I still love it
though) wasn't powerful enough to run anything, really, and the screen was
super small. I noticed using arrows key was super uncomfortable because yes,
they were closer to the actual home row but they were also smaller, clunkier
and harder to press. So I decided to force myself to use hjkl and disable
arrow keys. It was definitely one of the best decisions of my (coding) life.
Just comfortably resting your hands on the home row (either laptop keyboard or
normal one) simply makes your typing more relaxed and after the couple of
weeks (months?) struggling with left/right (up and down was fairly easy) you
really stop noticing it.

Funnily enough, I re-enabled arrow keys a year or so ago and I haven't really
felt the temptation to use them anymore.

DISCLAIMER: This turned me into a super slow and awkward typist when I am
trying to work on text in an editor that does not support vim mode (like
google docs for example). I have several documents around with
jjjkkjhjjhjjllljh unfortunately.

------
danso
I've always wanted to learn vim, as so many great coders use it and swear by
it, and it doesn't seem fundamentally harder than any other power-user skill.
My biggest fear is that I work with novices (who are using something like
Sublime) on a regular basis, and it's more friction than it's worth to switch
between the two kinds of muscle memories.

Also...maybe I don't write/edit enough code to justify learning vim? I mean,
both measured in lines and in number of projects. I'd like to think I've
advanced to the point where I'm spending 95% of my time thinking and 5% of my
time actually typing in code...being able to quickly grep and navigate through
Sublime Text is definitely a vital asset, but I'm not sure how much vim will
add to my overall efficiency.

~~~
nkuttler
If you have tools that work for you I don't see a reason to change. I use vim
because it's a great editor, can run in a terminal, and is open source. I know
the producer won't go out of business.

~~~
danso
Ah yes...the ability to use in a terminal is a huge thing. That ubiquity was
not important to me a year ago, but now I'm at a Unix shell so often that I
most definitely feel the pain of doing quickie scripting via nano/pico. Hmm, I
think you've convinced me :)

------
cellover
Interesting post!

I found another way to improve my vim skills and memory was to simply write a
wiki page with all the shortcuts / key strokes I learned or used. It has a big
benefit for me of anchoring things in my memory.

Always having it open when in vim, referring to it often, adding things,
moving things, reorganizing categories was a huge benefit for me.

Here is a screenshot of my wiki page index:

[http://imgur.com/my7lJJG](http://imgur.com/my7lJJG)

Also, having ones' dotfiles synced on github can be highly beneficial as your
vim env / plugins will be consistent between desktop / laptop / office /
friends' place.

[Edit] - cosmetics

~~~
quickpost
Would you be willing to share the HTML for your wiki page?

Just looking at the table of contents, it seems really useful for those of us
trying to learn vim compared to the normal cheat sheet that looks like a
periodic table...

~~~
cellover
Sure! Here it is:

[http://pastebin.com/BbJv6sWX](http://pastebin.com/BbJv6sWX)

It's raw HTML, sorry for the format :)

Note that I have the same kind of stuff for everything linux related:

[http://imgur.com/fI12YY5](http://imgur.com/fI12YY5)

~~~
quickpost
Great, thanks!

------
cschmidt
There is finally a good 'first' book about learning Vim, that just came out
this week: Pro Vim

www.amazon.com/Pro-Vim-Mark-McDonnell/dp/1484202511/

He sets you up with a reasonable .vimrc to start, which I think it key to get
over the bad defaults. He starts at the beginning, and takes you well beyond
what vimtutor covers.

I'm working my way through it now.

I'd also suggest vimcheatsheet.com, for something to hang on the wall. I just
don't get the cheatsheets that have a keyboard, since I don't really think
about the location of the keys I'm typing.

------
kornakiewicz
Considering that learning Emacs is comparably hard as learning Vim I think
that second advice is not always right, especially when the pet project is
developed in language you're learning and not familiar with - which is often
the case. It's often hard to learn new keybindings, new syntax, new workflow,
new idioms and maybe even new paradigm. Sometimes it's simply too much for
evening time, when I want to do something for pleasure.

------
sophacles
I've been using vim pretty much full time since around 2000. The one important
thing to accept about it: you'll never know all of it. It's just huge. (but
you'll never know all of any big dev environment - such is the life of a
software dev). To get really good with it, after the basics, I just kept (and
still do) in mind that "there's probably a better/easier/faster way to do
this". Then roughly once a quarter I'll spend an afternoon figuring out how to
do something new, and consciously focus on incorporating it into my workflow.
Just like I would with any other tool or technique.

Just because it's "old school stuff like vim" doesn't mean it isn't worth
learning. I don't know how it's viewed so differently than say, learning how
to use containers, or learning how to do event based programming, or any other
concept that slows you down for a little before making you more productive.

------
vegabook
For me, mapped caps lock to escape and thereafter never looked back. I found
reaching to the top left of my keyboard was breaking my concentration.
Especially given I touch type.

Also visualbell is almost mandatory otherwise "beep mode" was enough to drive
me crazy.

------
heyts
I have been meaning to learn Vim for a while but everytime I was trying I
ended up being overwhelmed by the number of command (and also frankly, the
weird syntax of .vimrc).

I finally took a step by step approach and started with a very minimal .vimrc
and worked my way up from there, solving real problems I ran into. I think the
key is to choose your battle.

Also this helped me understand the core concepts of how Vim operates:
[https://pragprog.com/book/dnvim/practical-
vim](https://pragprog.com/book/dnvim/practical-vim)

~~~
couchand
One thing to remember about your .vimrc file is that it's just a list of
commands. What's the command to expand tabs? _:set et_. And the corresponding
.vimrc setting? _set et_.

One fun thing to do to a friend is _echo q >> ~/.vimrc_.

------
cjjuice
The most important thing I would say to anybody that wants to use vim is
relax! Here are some steps I think will be helpful:

1 ) Install vim with janus and use gvim/macvim. This will allow you to use vim
pretty close to your previous editor.

2) Learn hjkl movement and how to move between insert/movement/visual modes.

3) Try to use them as much as possible. It's ok if you use arrow keys or mouse
from time to time.

4) Introduce no more than one additional feature a week.

5) Have fun! There is no "right way" to use vim. Use it how you see fit.

~~~
joshfinnie
I am still on the fence about the usefulness of Janus as someone starting with
Vim. Sure it gets you closer to ST, but is that really the end goal? Why not
still use ST?

------
kev6168
Vim's usefulness comes from the combined effects of many Vim commands, also
the benefit of a unique way of doing things. Sadly this combination is hardly
available after only a few hours or a day's study. Knowing only a few commands
won't give you much reward, and without immediate reward, people often lose
motivation to continue.

IMHO a good approach is to devote one or two months' available time, make
yourself super focused, just read, memorize and practice, whenever and
wherever you can. Also try not to use Vim for actual work in this stage.
Practice a lot with small scripts.

After a month or two of violently focused study/practice, you will either stop
for whatever reason (that's OK because the knowledge gained will be useful for
the rest of your career), or you have become good at 30 or 40 Vim
commands/options/tricks, the combination of them actually make you more
productive than before. The reward is sweeeet, so the learning goes on,
probably for many more years.

------
cnp
I went the flashcard route, but used Wunderlist instead. I would look at it at
night before bed, and in the morning right after I woke up. Using this
technique I felt totally proficient after about a month, with the ability to
get work done after about a week.

------
samuell
For me, what finally worked, after many other attempts, was:

1\. Run through vimtutor thoroughly [~30 mins].

2\. While doing that, memorize the 10-15 commands in the tutorial that stick.
Leave the rest (for a later time).

3\. Start using vim full-time from now on.

Worked perfect!

------
larrybolt
What made the difference for me was a Vim version with a project/file drawler,
like the one by alloy:
[https://github.com/alloy/macvim](https://github.com/alloy/macvim)

After a while I got fluent enough with vim to switch to NERDTree.

Btw, such a shame vimR ([http://vimr.org/](http://vimr.org/)) wasn't around
back when I started using vim, it looks awesome to learn vim-motions but still
be able sometimes to use insert-mode and mouse if you have to get something
done quickly.

------
chestervonwinch
Perhaps this is stating the obvious, but for me, the biggest thing was to not
allow myself to fall back on my normal editor. Otherwise, the path of least
resistance is easiest to follow.

------
gnuvince
[Two steps, eh?]([http://knowyourmeme.com/photos/572078-how-to-draw-an-
owl](http://knowyourmeme.com/photos/572078-how-to-draw-an-owl))

------
somehnreader
I used vim for a long time on servers, and only there to make quick edits and
wasn't very good at it.

I bought a new laptop recently and just didn't install any text editors. I had
a deadline a month away and a project where I was familiar with the existing
technologies.

That motivated me enough.

Add a bit of vimgolf and a lot of googling and here I am using vim for
everything, everywhere. I occasionally catch myself writing emails in vim and
then just copying them into Mail before I fire them off.

------
mwfogleman
I found Anki / spaced repetition helpful when learning (still learning, always
learning) Emacs. I make cloze deletion cards for the commands and their
explanations.

~~~
jmr0
Agreed. Especially for the more advanced or less commonly used vim/ed
shortcuts, adding them to my general Anki deck was invaluable. I went through
"Practical Vim" by Drew Neil and added all the useful shortcuts to the deck,
and whenever they would come up for review I would also try my best to put
them to use that same day. The card format would be question/answer e.g. "how
do you split a window vertically?"

I also used this approach to familiarize myself with the various unix tools I
don't necessarily use daily (sed, awk, etc)

------
snarfy
Still relevant:
[https://news.ycombinator.com/item?id=2911930](https://news.ycombinator.com/item?id=2911930)

------
userbinator
Vim is a huge editor but I don't think the subset of commands that are
absolutely necessary to do any editing at all is difficult to memorise; from
memory, these are the ones I started with:

hjkl i Esc or ^[ :w :q :q! :wq

~~~
cosarara97
Also, if you want to learn hjkl you just have to play some NetHack ;)

------
jumpwah
But that _was_ what Ornstein meant by cheatsheet. Anyways, why did you "want
to learn Vim for a long time", did you feel limited by st?

~~~
briandear
Vim is much more efficient. For example, within Tmux, one never needs to leave
the terminal; with ST, there's a frequent switching cost which compounds over
the course of a day. If one were to put Tim Pope up against an ST master, it's
almost certain Pope would win.

~~~
wyclif
I love the iTerm2 + tmux + vim + zsh environment. It takes a little time to
figure out how to juggle the configuration for them, but once you do, it's
super efficient.

~~~
joshfinnie
Are you dotfiles openly available? I have the same set of tools, but still
find things are slightly off... would love to compare notes.

------
stemc43
I'm only using Vim for server-side config editing.

And then a good full-fledged IDE for any large software development tasks.

~~~
desdiv
The two aren't completely mutually exclusive. There are Vim emulators for
pretty much every popular IDE out there.

~~~
hoggle
That's also how I've been doing it for some time now - best of both worlds!

Sometimes it can get a little flaky though as recently there were some
glitches in the IdeaVim plugin and it hurt my productivity badly (I'm so much
faster in Vim mode). The issues have fortunately been fixed by now.

I had always been struggling with Vim for bigger projects because I had to
waste many good hours over highly individual sets of dotfiles with plugins
like Nerdtree and others (integrated debugging, jumping to function
definitions etc) I could have been programming instead... IDEs like Xcode and
RubyMine are tightly integrated with their domain out of the box so to me
there is not much I could rationalize about in terms of using Vim
(unfortunately).

I even picked up WebStorm for node/js/html development recently, naturally
with the IdeaVim plugin activated at all times :)

------
icantthinkofone
Step one should be to get it out of your head that vim is hard or hard to
learn. Sitting with my son, years ago, I got him doing simple editing of files
for me proficiently in less than five minutes. Deleting words and lines and
selecting whole paragraphs and sections. Copying and pasting.

He was 15. vim is easy.

------
sgt101
1) Having to because the environment only supported Vim and was locked down,
and my job depended on it. 2) There is no 2

Because if there is no (1) then why would you?!!!

