4 ms·
Advanced vim tips and tricks
- yangyang 17y agoNot really "advanced": most of this is pretty basic - includes cursor movement, searching as well as some more interesting stuff.
- babo 17y agoBasic 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.
- yangyang 17y agoDon't get me wrong - it's not a bad collection. I'm just commenting on the HN headline.
- mattyb 17y agoThis 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.
- chancho 17y agoPutting \c and \C in the search pattern can also be used to turn case sensitivity off or on, respectively, for just that pattern.
- mbenjaminsmith 17y agoI love vim. That's all I have to share.
- travisjeffery 17y agoThe 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.
- mace 17y agoVim Recipes: http://vim.runpaint.org/toc/ http://vim.runpaint.org/toc/ A Byte of Vim: http://www.swaroopch.com/notes/Vim http://www.swaroopch.com/notes/Vim This cheatsheet has worked really well for me: http://www.viemu.com/vi-vim-cheat-sheet.gif http://www.viemu.com/vi-vim-cheat-sheet.gif
- yangyang 17y agoVim's :help is extensive. Try :help quickref. vimtutor is good for getting started too.
- 321abc 17y agoSome other great vim resources: Vim tips wiki: http://vim.wikia.com/wiki/Main_Page http://vim.wikia.com/wiki/Main_Page The best collection of vim scripts: http://www.vim.org http://www.vim.org #vim on freenode