News for hackers. Stuff that matters.
Re:Advanced vim tips and tricks by mattyb on Saturday August 01, 2009 @04:46PM (#736649)
This misses out on lots of stuff. Two weeks ago, I set aside an entire day and read a bunch of Vim tutorials. My cheat sheet filled up 2 8.5"x11" pages. Here are a few gems:

gg -> go to the top of the file.

G -> go to the bottom.

:set splitright -> makes :vs open the file on the right

:set splitbottom -> makes :sp open on the bottom

Ctrl-w cycles through split windows. Ctrl-[h,j,k,l] goes to the window in that direction [left, down, up, right].

When either :vs or :sp are invoked without filenames, they open the current buffer. Very useful for looking at 2 sections of the same file at once.

:tabe [file] -> how could this get forgotten? Opens the file in a new tab.

:set number -> shows line numbers.

[Line#]G -> jumps to that line.

O -> capital oh, inserts a blank line above the current line and goes into insert mode. Perfect for comments.

:set ic -> ignores case for searching, usually useful. :set noic makes searching case sensitive again. (:set no[setting] turns that setting off)

:set lbr -> visual word wrap.

Text objects are also damn cool. In visual mode (v):

i" -> selects the contents of quotes.

i( -> select the contents of parens.

i[ -> selects the contents of square brackets.

i{ -> selects the contents of curly brackets.

Using a instead of i for the above commands selects the delimiter also.

>> -> indents. << does the opposite.

% -> goes to matching paren/bracket. Great for debugging.

* -> go to next instance of current word. # to go to previous instance. Good for cycling through function definitions.

Edit: formatting, more commands.

Re:Advanced vim tips and tricks by chancho on Saturday August 01, 2009 @04:51PM (#736653)
Putting \c and \C in the search pattern can also be used to turn case sensitivity off or on, respectively, for just that pattern.
Re:Advanced vim tips and tricks by yangyang on Saturday August 01, 2009 @03:19PM (#736543)
Not really "advanced": most of this is pretty basic - includes cursor movement, searching as well as some more interesting stuff.
Re:Advanced vim tips and tricks by babo on Saturday August 01, 2009 @03:55PM (#736587)
Basic or not, this is a fine collection of VIM patterns. While vim help is OK but far from usable, it's just too long to read without a proper formatting. This site is just the opposite, short and easy to navigate tips, quite handy as a reference.
Re:Advanced vim tips and tricks by yangyang on Saturday August 01, 2009 @04:19PM (#736619)
Don't get me wrong - it's not a bad collection. I'm just commenting on the HN headline.
Re:Advanced vim tips and tricks by travisjeffery on Saturday August 01, 2009 @05:35PM (#736705)
The OSS book, Vim Recipes is really great as well, and if you know something that isn't on there just fork it and push it yourself.

Here's another one a Byte of Vim, also free on a CC license, but not as good as the Vim Recipes I've found.

Re:Advanced vim tips and tricks by mace on Saturday August 01, 2009 @06:05PM (#736735)
Vim Recipes: http://vim.runpaint.org/toc/

A Byte of Vim: http://www.swaroopch.com/notes/Vim

This cheatsheet has worked really well for me: http://www.viemu.com/vi-vim-cheat-sheet.gif

Re:Advanced vim tips and tricks by yangyang on Saturday August 01, 2009 @07:34PM (#736838)
Vim's :help is extensive. Try :help quickref.

vimtutor is good for getting started too.

Re:Advanced vim tips and tricks by mbenjaminsmith on Saturday August 01, 2009 @04:59PM (#736662)
I love vim. That's all I have to share.
Re:Advanced vim tips and tricks by 321abc on Saturday August 01, 2009 @07:39PM (#736842)
Some other great vim resources:

Vim tips wiki: http://vim.wikia.com/wiki/Main_Page

The best collection of vim scripts: http://www.vim.org

#vim on freenode