Skip to content

Instantly share code, notes, and snippets.

@nathanharper
Last active August 29, 2015 14:09
Show Gist options
  • Save nathanharper/9c9c831ebc2e2cfd93b5 to your computer and use it in GitHub Desktop.
Save nathanharper/9c9c831ebc2e2cfd93b5 to your computer and use it in GitHub Desktop.
function! BddFindFunction()
ruby<<E___
line = VIM::Buffer.current.line
if /^\s*(?:[Gg]iven|[Ww]hen|[Tt]hen|[Bb]ut|[Aa]nd)\s+"([^"]+)".*$/ =~ line
function_name = $1.gsub(/[^A-Za-z0-9\s]/, "").gsub(/\s+/, "_").downcase
Vim::command('call searchpos("def ' + function_name + '")')
else
Vim::message "Not a BDD :^("
end
E___
endfunction
nnoremap <silent> '' :call BddFindFunction()<CR>
@nathanharper
Copy link
Author

Seems like this crashes sometimes when it can't find a matching line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment