TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Advanced vim tips and tricks

21 点作者 bnmrrs将近 16 年前

6 条评论

mattyb将近 16 年前
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 未加载
yangyang将近 16 年前
Not really "advanced": most of this is pretty basic - includes cursor movement, searching as well as some more interesting stuff.
评论 #736587 未加载
travisjeffery将近 16 年前
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 未加载
yangyang将近 16 年前
Vim's :help is extensive. Try :help quickref.<p>vimtutor is good for getting started too.
mbenjaminsmith将近 16 年前
I love vim. That's all I have to share.
321abc将近 16 年前
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