Skip to content

Instantly share code, notes, and snippets.

@dbalatero
Created March 23, 2020 18:51
Show Gist options
  • Save dbalatero/b2e2511506c48ce6ddfdad60a3b543bd to your computer and use it in GitHub Desktop.
Save dbalatero/b2e2511506c48ce6ddfdad60a3b543bd to your computer and use it in GitHub Desktop.
# some pdf file
def applicant_name
{ "form[0].applicant[1].name" => answers.applicant.name }
end
def applicant_email
{ "form[0].applicant[1].email" => answers.applicant.email }
end
# some pdf file
label "form[0].applicant[1].name"
field :applicant_name do
answers.applicant.name
end
label "form[0].applicant[1].email"
field :applicant_email do
answers.applicant.email
end
# move your cursor to line 1
# start macro recording
qa
# move to inside of label ""
/label
<enter>
f"
l
# yank inside quotes to register "l"
"lyi"
# delete line
dd
# jump to field symbol name
f:
l
# yank word into register "f"
"fyw
# replace with a method definition
dd
O
def
<esc>
"fp
# change method body
j
0
w
i
{ ""
<esc>
"lp
2w
i
=>
<esc>
A
}
<esc>
j
# press q again to stop recording
q
# the first block will be changed
# fire the macro a second time with:
@a
# second block is now changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment