Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Created November 23, 2011 22:24
Show Gist options
  • Save bjeanes/1390108 to your computer and use it in GitHub Desktop.
Save bjeanes/1390108 to your computer and use it in GitHub Desktop.
Easily fold everything not relevant to your current spec

Easily fold everything not relevant to your current spec

Usage / Example

Just hit <Leader>rf (rspec focus) to fold all example groups in the entire file except the full hierarchy to your spec that your cursor is inside. The current example is automatically centered on your screen, when possible.

This lets you easily see all the context/describe blocks that apply just to the current spec. See:

example

To re-expand all examples just hit zR

TODO (see image for more detail)

  1. Make all relevant before/let/subject blocks stay open
  2. All separately folded example groups above and below the current one could be collapsed into a single fold
  3. Only set up mapping for files ending in *_spec.rb
  4. Make it work for Jasmine

planned improvements

nmap <silent> <Leader>rf mr:set foldmethod=syntax<CR>zMzv?\v^\s*(it\|example)<CR>zz:noh<CR>`r:delmarks r<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment