let $RUBYPATH = 'lib' function! s:run_example() if &ft != "ruby" " Not ruby, do nothing. return endif " look for it ", with no word character just before ‘it’ let line = search( '\w\@ 0 execute "!" . cmd else echo "No rspec example found at or before cursor position." endif endfun nmap t :call run_example()