TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Advanced vim tips and tricks

21 pointsby bnmrrsalmost 16 years ago

6 comments

mattybalmost 16 years ago
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:<p>gg -&#62; go to the top of the file.<p>G -&#62; go to the bottom.<p>:set splitright -&#62; makes :vs open the file on the right<p>:set splitbottom -&#62; makes :sp open on the bottom<p>Ctrl-w cycles through split windows. Ctrl-[h,j,k,l] goes to the window in that direction [left, down, up, right].<p>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.<p>:tabe [file] -&#62; how could this get forgotten? Opens the file in a new tab.<p>:set number -&#62; shows line numbers.<p>[Line#]G -&#62; jumps to that line.<p>O -&#62; capital oh, inserts a blank line above the current line and goes into insert mode. Perfect for comments.<p>:set ic -&#62; ignores case for searching, usually useful. :set noic makes searching case sensitive again. (:set no[setting] turns that setting off)<p>:set lbr -&#62; visual word wrap.<p>Text objects are also damn cool. In visual mode (v):<p>i" -&#62; selects the contents of quotes.<p>i( -&#62; select the contents of parens.<p>i[ -&#62; selects the contents of square brackets.<p>i{ -&#62; selects the contents of curly brackets.<p>Using a instead of i for the above commands selects the delimiter also.<p>&#62;&#62; -&#62; indents. &#60;&#60; does the opposite.<p>% -&#62; goes to matching paren/bracket. Great for debugging.<p>* -&#62; go to next instance of current word. # to go to previous instance. Good for cycling through function definitions.<p>Edit: formatting, more commands.
评论 #736653 未加载
yangyangalmost 16 years ago
Not really "advanced": most of this is pretty basic - includes cursor movement, searching as well as some more interesting stuff.
评论 #736587 未加载
travisjefferyalmost 16 years ago
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.<p>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.
评论 #736735 未加载
yangyangalmost 16 years ago
Vim's :help is extensive. Try :help quickref.<p>vimtutor is good for getting started too.
mbenjaminsmithalmost 16 years ago
I love vim. That's all I have to share.
321abcalmost 16 years ago
Some other great vim resources:<p>Vim tips wiki: <a href="http://vim.wikia.com/wiki/Main_Page" rel="nofollow">http://vim.wikia.com/wiki/Main_Page</a><p>The best collection of vim scripts: <a href="http://www.vim.org" rel="nofollow">http://www.vim.org</a><p>#vim on freenode