Skip to content

Instantly share code, notes, and snippets.

@apux
Last active August 4, 2017 15:35
Show Gist options
  • Save apux/3714674 to your computer and use it in GitHub Desktop.
Save apux/3714674 to your computer and use it in GitHub Desktop.
Regex for vim

hash rocket to colon

:%s/:\(\w\+\)\( *\)=>\( *\)/\1: /g

clean trailing spaces

:%s/\s\+$//

Rspec 2 to rspec 3

Preferably in this very order

stub

any_instance

:%s/^\( \+\)\(.\+\)\.any_instance.stub/\1allow_any_instance_of(\2).to receive/g

stub_chain

:%s/^\( \+\)\(.\+\)\.stub_chain/\1allow(\2).to receive_message_chain/g

stub

:%s/^\( \+\)\(.\+\)\.stub/\1allow(\2).to receive/g

should to expect

:%s/^\( \+\)\(.\+\)\.should\( \+\)be_true/\1expect(\2).to\3be_truthy/g
:%s/^\( \+\)\(.\+\)\.should\( \+\)be_false/\1expect(\2).to\3be_falsey/g
:%s/^\( \+\)\(.\+\)\.should\( \+\)== nil/\1expect(\2).to\3be_nil/g
:%s/^\( \+\)\(.\+\)\.should\( \+\)==/\1expect(\2).to\3eq/g
:%s/^\( \+\)\(.\+\)\.should\( \+\)=\~/\1expect(\2).to\3match/g
:%s/^\( \+\)\(.\+\)\.should_not\( \+\)==/\1expect(\2).not_to\3eq/g
:%s/^\( \+\)\(.\+\)\.should/\1expect(\2).to/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment