Skip to content

Instantly share code, notes, and snippets.

@wolverian
Last active August 29, 2015 13:57
Show Gist options
  • Save wolverian/9504932 to your computer and use it in GitHub Desktop.
Save wolverian/9504932 to your computer and use it in GitHub Desktop.
function! ToggleOnly()
let l:view = winsaveview()
if search("\\v( |^)(it|describe)", "b")
if search("\\.only", "c", line("."))
%s/\.only//g
else
let l:cur = getpos(".")
%s/\.only//ge
call setpos(".", l:cur)
normal Ea.only
endif
endif
call winrestview(l:view)
endfunction
nnoremap <leader>o :call ToggleOnly()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment