

Ask HN: What's the best way to get started with Vi(m) - sh1mmer

The title says it all. It's one of the things I've been meaning to do, but never quite did. Any suggestions? I'm a TextMate power user currently.
======
samdk
I think with something like Vim it's best to get a grasp on the very basics
(saving/opening documents, moving into and out of insert mode, navigating with
hjkl) and then add one of two things at a time as you get comfortable with
those. If you try to do everything at once you just end up getting
overwhelmed.

I didn't really start to like Vim until I started playing around with my
.vimrc file. There were too many minor irritants and things I wanted changed.
An Ask HN on the subject came in very handy:
<http://news.ycombinator.com/item?id=856051>

Mine (along with a few other minor customizations) is at
<http://github.com/samdk/vimconf/blob/master/dotvimrc> if you'd like to take a
look.

Some other good resources: <http://dotfiles.org/.vimrc> <http://www.vi-
improved.org/vimrc.php>

------
ananthrk
In addition to all the excellent suggestions here, I will also suggest reading
the free book "A Byte of Vim"
(<http://www.swaroopch.com/notes/Vim_en:Table_of_Contents>).

This is how the book introduces itself:

 _"A Byte of Vim" is a book which aims to help you to learn how to use the Vim
editor (version 7), even if all you know is how to use the computer keyboard.

The first part of this book is meant for new users who want to understand what
Vim is and learn how to use it.

The second part of this book is for people who already know how to use Vim and
want to learn about features that make Vim so powerful, such as windows and
tabs, personal information management, making it a programmer's editor, how to
extend Vim with your own plugins, and more._

~~~
suren
Byte of Vim is one of the Best technical writings for newbies and pros alike.
I had a wonderful time reading it and the way I use vim after that has changed
a lots!

------
derwiki
Type `vimtutor` on your command line and hit enter.

~~~
sophacles
Then spend a week doing as much as possible from within vim. You will start to
get the basic hang of it. Then as you want to do other things, _assume vim can
do them for you_ and try and figure out how. #vim on freenode is good for
this, although much of the help comes in the form of :he X. This means, read
the documentation, the topic keyword is x. You literally type that into the
editor command line :) The vim documentation is _very_ good -- in fact just
reading a few things extra every time you use vim is a good idea.

A final note: I have been using vim for my main editor for years now, and
still learn new stuff all the time. Playing with new scripts, finding new bits
of workflow, and getting really fast at it all take time. This is natural. I
try and pick a couple new things a week an use them. Sometimes I will then
forget about them for weeks, months or years because I think they are useless,
but "rediscover" them only to use them all the time. Its actually quite fun.

------
jraines
Check out vimcasts.org. The guy who makes them even occasionally refers to how
to do things in vim that he likes in TextMate.

------
th
To become a vim power user, you will really need to understand how and why vim
works the way it does and how you should think about editing while using vim.
Once you have gone through some of the great tutorials on basic vim usage take
a look at these:

Stay out of insert mode: [http://cloudhead.io/2010/04/24/staying-the-hell-out-
of-inser...](http://cloudhead.io/2010/04/24/staying-the-hell-out-of-insert-
mode/)

Good explanation of how vim commands are actually formulated (Stack Overflow
answer): [http://stackoverflow.com/questions/1218390/what-is-your-
most...](http://stackoverflow.com/questions/1218390/what-is-your-most-
productive-shortcut-with-vim/1220118#1220118)

------
markkoberlein
This is the cheat sheet that I used to get started:
<http://home.uchicago.edu/~gan/file/vim.pdf>

Learn the basics first:

1\. Basic movement (h l k j)

2\. Insertion mode (i), deletion (x), selections/visual Mode (v), copying/yank
(y), pasting/put (p), and exit insertion mode (esc)

Once you learn those the rest is pretty easy to pick up.

I should warn you though, once you get used to the key commands it's hard to
go back to another editor.

~~~
grayrest
I've always thought that the f and t motions along with I and A to switch to
insert mode, and . (repeat) should be included in the basic motions and text
objects should be the next step.

They're relatively simple to remember and you can string them together to
accomplish a lot more than the character-wise to word-wise motion progression
I've seen in most vim intros.

------
mbenjaminsmith
Assuming you're on Mac you'll need to set up a decent .vimrc to enable syntax
highlighting, indentation and some other bits. Vim is a different beast
depending on how it's set up.

The built in tutorial is a decent place to start. I think that's the only
thing I did apart from editing code. It takes a while to get over the hump but
it's worth it.

I also suggest remapping your CAPS LOCK key to ESC. PCKeyboard Hack is free
and simple to set up for that purpose. I've never liked the role of ESC in vi.
It's too far away from the home keys.

If you learn to love the efficiency, I'd suggest looking at Komodo Edit or
another editor that has vim key mappings. I prefer Komodo because it's vim
plus code completion (I'm not aware of a vim solution for that) and a bunch of
other bits that will save time.

~~~
nash
Not sure what features komodo has for completion, but between the built in
omni-completion in vim 7, it's pretty powerful which will complete on symbols
in all loaded files and in things like header files. That's activated by
Control-X Control-O. Control-P or Control-N in insert mode.

There are various plugins available to make it smarter for C++ and other
languages (so it only searches in appropriate namespaces and the like).

------
yesimahuman
IMO the only thing you can do is to start writing real code and force yourself
to use it. Honestly, the vim help stuff was almost useless to me at first
because I would forget it as soon as I learned it, since I didn't understand
the vi mindset.

You will notice a big drop in productivity at first, but hopefully you should
notice yourself getting faster in a week or so.

------
jng
This was my best answer to the question, written 4 years ago, hope it helps:

[http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial...](http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html)

I also prepare this write up answering "Why vi?":

<http://www.viemu.com/a-why-vi-vim.html>

They've been on the HN front page a few times, too.

------
genieyclo
I'm surprised no one has mentioned Derek Wyatt's excellent series of videos.

See his blog page with links to his videos:
[http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-
novice...](http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice-
tutorial-videos/)

Or go to his Vimeo page where they all sit: <http://vimeo.com/user1690209>

------
ZeroGravitas
I found that being a touch-typist helped, since the concept of vim is to have
your hands on the home row using letter keys rather than arrows or mice. (I
happened to learn Dvorak but I'm sure Qwerty would have a similar impact on
getting the most out of vim). Plus it's a transferable and generally
recommended skill for programmers.

------
samratjp
I switch between vim and textmate. My favorite textmate/vim feature is column
select - in vim, its ctrl+v (<http://sethmason.com/2007/09/27/vim-tip-select-
column.html>) in textmate it's option+click.

Also, fwiw, Macvim may help retain vim usage.

------
wrinklz
Use the Vimperator firefox plugin, so you can exercise your Vim muscles while
you browse the internet.

------
icco
I just started using it do code everything I do. Found other coders I know
through IRC that know how to use it, and we traded tips. Over time I found my
self becoming more and more efficient with it. vimtutor, as mentioned in other
comments also works really well.

------
pmccool
As a long time vim user, I have to ask: what's the appeal?I use it because I
already knew vi, and I knew vi because it was the one editor I could be
confident of finding on any UNIX box.

I'm curious: what's the motivation for learning it from scratch?

~~~
whimsy
As opposed to doing what? Using a GUI editor? Using emacs?

vim is just as likely to be on any linux/os x box today as vi was to be on any
UNIX box when you were learning vi, and it's still very powerful today.

------
heresy
I learned Vim inside and out because it was the only Linux console editor at
the time that did syntax highlighting, and it kind of stuck.

Also, working in 80x50 with only the editor open for a couple of months kind
of gets you into the mode :)

------
saurabh
The way I learn to use my tools is I start customizing them, thereby
understanding how they work, how others use them and how I can utilize them.
Look for .vimrc's of other hackers. I learn't many things just from the
dotfiles.

------
philwelch
Attach this to a visible surface near your desk:
[http://r00tsecurity.org/db/cheat-sheets/SOFTWARE/Vi/vi-
vim-c...](http://r00tsecurity.org/db/cheat-sheets/SOFTWARE/Vi/vi-vim-cheat-
sheet.gif)

------
687
<http://vim.runpaint.org/> and seconding Vim wiki (<http://vim.wikia.com/>)

------
ppereira
I started by learning ed from "The Unix Programming Environment", and then vi.
By tackling vim directly, you may get swamped in the details.

------
pkrumins
Start with hjkl and see where it takes you. :)

------
nose
You can borrow my vim cheat sheet tomorrow.

------
andrewljohnson
Type this into your terminal: emacs

~~~
jimmyjim
On a more serious note, do please feel free to give any and all helpful advice
on how to get started with emacs. I'm okay with vim, I've been using it more
and less for about 2 years, but emacs has always seemed more esoteric and I
never did quite get the hang of it.

~~~
leif
Get a friend that uses it well and will be nearby (physically) for a few
months. I didn't learn until I spent a summer with Slava (coffeemug) at my
side willing to answer questions.

Find ways to do as much as you can of what you normally do with your computer
in emacs. If you use IRC a lot, use erc. If you use email a lot, try out gnus
or rmail. Don't try to replace your web browser with w3m, that's just stupid
and you'll hate it.

Also, find a mode you really like. This will keep you using emacs whether you
like it or not, until you really do like it. For me, it was gdb-mode. For
most, it's one of the inferior repl modes (slime for lisp or clojure or
whatever, ruby, python).

I've heard good things about <http://github.com/technomancy/emacs-starter-
kit>, but I've never tried it.

~~~
jimmyjim
Thanks for the very helpful answer, it's just what I wanted. :)

I do use IRC a lot, and I'll start using erc per your suggestion. One
question, is there any way to get spell-checking on it? I'm hoping the
solution is as straight-forward as x-chat's (this screenshot demonstrates it
fairly well: <http://i42.tinypic.com/rw2ljr.jpg> though, I don't require fancy
multi-language spell-checking, just an English spell-checker will do for me)

I wish I had a friend who used emacs! On that note -- anyone in this HN crowd
who uses emacs from Milwaukee? I'm willing to gift copious amounts of
chocolate (or whatever else you prefer) in exchange for even short periods of
guidance. :)

~~~
boskom
As for spelling I believe enabling flyspell-mode will do the job, i.e. M-x
flyspell-mode

