On Tue, May 5, 2009 at 7:37 AM, Reid Thompson <[email protected]> wrote: > got any pointers to links listing other examples?
The Vim tips [1] is a ridiculously huge collection of them. The problem is that it's huge and significant swaths of it are not going to be useful to you. The closest thing I know of a coherent collection is Efficient Editing in Vim [2], but that's just a start. Bram gave a google tech talk about building your idioms (though he didn't call it that) and the general idea is that you should notice when you're repeating yourself and figure out the correct way to do it. This is no different from noticing copying/pasting code and upping your abstraction to cover future cases. Everybody's idioms are different. [1] http://vim.wikia.com/wiki/Category:VimTip [2] http://jmcpherson.org/editing.html My general tips beyond Efficient Editing are: * know and love the f and t motions and the text objects. There are a LOT of tricks with these, far too many to list. E.g. =i{ indents your current block in a c like language, ct, is useful for replacing arguments, swapping nested array access ``a['o|ne']['two']`` ->``a['two']|['one']`` is da[%p (or P if you're going the other way), etc, etc, etc. Text object motions are particularly useful because they're generally effective when you repeat. * % jumps between parens and whatnot but it also SEARCHES FORWARD and jumps if you're not on a matchpair character. Primary use for this is function calls/definitions * `` is your friend. The rest of the mark movements are useful but `` is the best. * I love visual block mode for ad hoc linewise stuff, I inserts on every line, A appends on every line. * I use :'<,'>s/pattern/replace/ daily, frequently in context with a visual selection via % or `a * \zs and \ze in patterns are very convenient * Fastest way to remove the word under the cursor from the entire file is *:%s///g and you get back to where you started with `` * I don't find the ' motion useful over `, so I :nnoremap ' @a in my .vimrc and always do macros into the a register so I can trivially repeat it with '. It's then generally <c-n>' to jump to the next location and re-execute the macro * The J and gJ commands * :g and :g! are selectively handy, particularly :g!/pattern/d, :g/^/m0, :g/pattern/m$ Beyond that, you get into more setup dependent idioms. Some examples (| is cursor): * I like splits for editing multiple files and :map <C-J> <C-W>j<C-W>_ (and same for <C-K>) for flipping between files. * I like using <Leader> mappings for toggling settings (e.g. \p toggles paste). Examples: :noremap <silent> <Leader>p :se invpaste<CR>:echo &paste ? "Paste ON!" : "Paste off"<CR> :noremap <silent> <Leader>l :se invlist<CR> :noremap <silent> <Leader>n :se invhlsearch<CR> * if my current line looks like ``get(a['foo|'])``, typing ) gets me ``get(a['foo'])|`` due to my autoclose.vim plugin * using the same ``get(a['foo|'])``, <esc>cs'" gets me ``get(a["foo|"])`` while csw{ produces ``get(a['{foo|}'])`` both due to the surround.vim plugin * If I have ``<tr|``, closing the tag with > produces ``<tr>|</tr>`` and a second > splits the tags onto different lines with the cursor between them at the correct indent. This is from a special xml.vim * I have an extensive set of snippets that I'm migrating from snippetsEmu to the most excellent snipMate. Using a snippets plugin and curating your own set of snippets is the bee's knees. I don't generally like other people's snippets but mine are probably the biggest single speedup in my toolkit. I actually use ; as my snippet expansion because I like to keep tab for word completion. You just build them up over time. A lot aren't useful to other people, hence why I call them idioms. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
