

Use Vim Like A Pro - telemachos
http://tottinge.blogsome.com/use-vim-like-a-pro

======
symkat
Pet peeve: Vim should be spelled "Vim," not "VIM."(1) Consistency in case
would also make it easier to read in my opinion, Vim/VIM seem to be used
interchangeably throughout the article.(2) Other than that, this is a good
crash course. =)

1 See spelling in use at <http://www.vim.org/about.php>

2 "Vim has a small footprint in RAM and on the CPU. A given system can support
a great many VIM users at once."

~~~
mahmud
I don't think executable size makes a huge difference for this type of
application. All static sections of a given binary is shared among all users;
code, globals, and shared libraries. Even the non-static parts are copied on
write.

~~~
pyre
He was quoting an excerpt from the article to illustrate the usage Vim/VIM
inter-changably.

~~~
mahmud
Sorry, the technical errors were more glaring to me than spelling.

------
adimitrov
There's a myriad of vim-tutorials around the Net, but I find that people
usually tend to forget that vim has a built-in tutorial. Of all the ones I've
found, this is really one of the best. Most importantly, it's interactive, and
I'm a 'learning-by-doing' person. Just type `vimtutor` at the command prompt
(also `gvimtutor`.)

Not to diminish on the author's efforts. The tutorial he wrote taught me about
vim's capabilities in directory mode — I would usually just quit every time I
accidentally ended up in it.

------
gfodor
Another important vim tip for me that wasn't in there and might be one for the
author himself: you can use ctrl-C or ctrl-[ instead of ESC to exit insert
mode. This, combined with re-mapping capslock to control, is a big, big win.

~~~
chancho
Ctrl-c and ctrl-[ are not the same. There are times when latter completes the
insert session (same as esc) while the former aborts it, e.g. visual block
insertion with (ctrl-v jjjj I)

Also, the happy haacking keyboard already puts control in its proper place and
puts esc where ~ normally is, which is close enough that you don't really need
to remap it. Best vim keyboard ever.

~~~
pyre
It's more helpful to think of ctrl-[ as an analog to ESC (this also works in
Emacs, irssi, etc as well IIRC). Ctrl-c just happens to work for exiting
Insert mode because ctrl-c is the 'abort' command, and technically Insert mode
is an operation.

Insert mode is not Vim's 'normal' mode. When you enter Insert Mode, you are
basically saying, "I'm stepping out of normal mode for a bit to enter some
text here." In this sense, hitting ctrl-c is telling Vim that you're aborting
your insert operation. (Though I could just be talking out of my ass, and it
was just bound that way as a convenience)

------
ivanzhao
Vim is ancient yet its idea can be quite advanced: we have 10 fingers so why
not use as many of them as possible?

It's like a puppet master wiring her fingers to fully express herself through
the puppet. In the case of programming, Vim is the wire and the puppet is the
code.

~~~
jrockway
Isn't it Emacs that encourages you to use all ten fingers at the same time?

~~~
graywh
No, Emacs encourages the growth of a sixth digit on the left hand.

------
davnola
If you enjoyed this, you should definitely check out
<http://http://vimcasts.org>.

I caught Drew's talk at Arrrrcamp on Friday and he is a fantastic explicator.
His Vim book for PragProg should be excellent.

~~~
hippich
<http://vimcasts.org> And thanx for great site!

------
ed
If you're learning Vim, I highly recommend installing Vimium for Chrome.

It's an amazing plugin that brings Vim-like keyboard mappings to the browser,
making it significantly easier to build muscle memory.

<http://vimium.github.com/>

~~~
kgroll
Or for Firefox - vimperator. <http://vimperator.org/vimperator>

~~~
ElbertF
Or Pentadactyl, a Vimperator fork:
<http://dactyl.sourceforge.net/pentadactyl/>

~~~
jordinl
I'm trying it but I don't find the way to enter insert mode... :i, doesn't
work, am I missing something?

------
wonderzombie
I might've found this out through HN, in which case this'll be redundant.
Still, I'll risk it: <http://vimcasts.org/> is a good resource.

This fellow puts up bite-sized, five minute screencasts of various Vim-related
features. Some of the 'casts are more advanced, and some of them are pretty
basic.

------
klochner
I recently switched to vim (macvim), and one thing bugs me that maybe someone
knows a fix for . . .

The padding between the left edge of the window (or the right edge of the line
numbers) and the interior text it ~0. I'd like just a little padding.

anyone?

~~~
gurraman

      :help numberwidth

~~~
klochner
It may be macvim specific, vim doesn't look as bad. I can distinguish text
from line numbers, but it bugs me that they touch.

I posted to superuser with an image to give you an idea of what I'm talking
about:

[http://superuser.com/questions/205553/how-can-i-add-some-
pad...](http://superuser.com/questions/205553/how-can-i-add-some-padding-to-
the-macvim-text-area)

~~~
gurraman
It's the same in terminal vim. A fix could be to change the background of the
linenumbering to something less obtrusive.

Example: <http://tinypic.com/r/f0u84/7>

~~~
klochner
great idea, worked like a charm. Thanks.

------
crazydiamond
<http://stevelosh.com/blog/2010/09/coming-home-to-vim/>

Doesn't look like anyone's posted this link as yet.

~~~
pyre
This was on HN a while back (assuming posted == 'posted this article' and !=
'posted this in the comments').

------
clvv
Also, :x is the short version of :wq(also available in vi). And some people
put their rc files up on github, here is my vimrc file:
<http://github.com/wei23/dotfiles/blob/master/.vimrc> I cherry-picked a lot of
useful features from different vimrc files on github and dotfiles.org

------
brianobush
I use emacs daily, but enjoy vi(m) on the side occasionally. Nice tips!

------
lmx
Another Vim tip: plugins can be amazingly useful.

The NERD Tree plugin gives you a directory tree that lets you easily move
between files and do filesystem operations.

<http://www.vim.org/scripts/script.php?script_id=1658>

------
micaelwidell
TextMate is getting older and older. I would like to try something else, but I
haven't yet found another editor with a sane file/folder sidebar, which is a
must for me. Any tips? The sidebars I've seen for emacs and vim either look
lika crap or use too big a font for them to be practical.

~~~
SkyMarshal
Check out Command-T also. Good discussion here:

<http://news.ycombinator.com/item?id=1688500>

------
expeditious
Looks like a great tutorial. Covers a lot of ground that others don't (such as
the star command, windowing commands, ctags use, etc.).

Vim certainly has a lot of ninja editing moves (however, I don't think my
development speed is particularly limited by my raw text editing speed).

------
crazydiamond
If you program, please try SnipMate.vim. There are plenty more very helpful
plugins, but this one is great and is programmable. And don't forget
pathogen.vim. Yankring, command-T or fuzzyfinder, surround, repeat, align, ack
and fugitive are others i recommend.

------
lelele
The ultimate Vim tip? Use GNU Emacs. Seriously.

Vim is a great editor, it just lacks a decent implementation; GNU Emacs is a
great OS, it just lacks a great editor. GNU Emacs + Viper + Vimpulse is what
you should learn and use for maximum effectiveness.

------
brianto2010
Awesome! I learned about zt, zb, zz, ^x ^f, and ^x ^i today. They'll
definitely come in handy.

~~~
Nervetattoo
Its amazing that after having read probably hundreds of Vim tutorials / guides
every user is able to learn something completely new from every one of them.
It sure scales.

This one brought ^T and ^D for indenting in insert mode to me, and starting
with -o/O as argument for opening multiple files in splits.

~~~
zmmz
One of the best resources for learning more about vim is the various .vimrc
files on github

A simple
[http://github.com/search?&q=vimrc](http://github.com/search?&q=vimrc) is a
goldmine for mastery.

------
hbt
There is also <http://jvi.sourceforge.net/> a netbeans module with vim like
behavior. Surprisingly, it has a lot of stuff.

------
melling
I'm in the Emacs camp. However, vi has a certain minimalistic efficiency to it
for development. Let me add that a pro might want to quit with :x instead of
:wq.

~~~
pyre
It's probably best to learn a bit of both, but specialize in one. Especially
since common tools like `less` use vim bindings. Examples:

* `less +23 file.txt` opens the file in less at line 23

* Searching in less works just like vim:
    
    
      /  -- starts a forward search
      ? -- starts a backward search
      n -- cycle through matches forward
      N -- cycle through matches backwards
    
     * Some movement keys are shared:
    
      gg -- go to the top of the file
      G  -- to go the bottom of the file
    

... etc ...

~~~
DennisP
Wow that's cool...what other tools do that sort of thing?

------
thomie
How do I contact the other of this piece?

"Yank from the current character to the end of the line into register y"

should be:

"yy$

instead of

"y$

~~~
telemachos
The author is Tim Ottinger. You can find him on Twitter[1] for example, pretty
easily.

[1] <http://twitter.com/#!/tottinge>

------
louisYuHoo
I've always remapped WW to save without quitting. I'm not sure why ZZ is
standard but not something like WW.

------
sagarun
Tip: 'vim -x filename.txt' asks for password and encrypts the file :-)

~~~
dchest
set cryptmethod=blowfish in 7.3 to _really_ encrypt it.

------
tectonic
What's the best way to jump to the implementation of a symbol in vim?

~~~
whimsy

       /symbol
    

Oh, it's a metacharacter?

    
    
       /\meta
    

\ escapes metacharacters

------
shimonamit
I remapped 'hjkl' to 'jkl;' and never looked back.

------
yuvadm
spectacular. now where's 'use emacs like a pro'?

~~~
symkat
emacs has a text editor too? I always just used it as an irc client...
(<http://delysid.org/emacs/erc.html>)

<http://www.emacswiki.org/emacs/EmacsCrashCourse> is fairly good for a quick
introduction to similar ways of doing things in emacs. =)

~~~
SkyMarshal
An IRC client? Funny, I thought it was personal organizer.

