Thread of Helix refactor examples in practical situations #12051
Unanswered
NikitaRevenco
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it's beneficial to have a thread where we can share how the helix motions can be used in practical applications to refactor code. Feel free to share yours here, if I have any cool ones in mind I'll also add a comment.
I'll start
Converting the following object into an array of tuples, each tuple's first element is the color name and the second is the color value
mr{[
to replace surrounding curly braces with square bracketsmi[
to select everything within the arrays
to enter select mode:<enter>
to place a cursor on every:
characterr,
to replace every:
with a,
(comma)t,;
to move cursor on each line to the ending comma, the semicolon collapses all selections to a single cursorvgs
to make a selection on each line from the beginning (excluding whitespace) up until, but excluding the commams[
to surround with square brackets (array)l
to move 1 character forwarde
to select until the end of each wordms"
to surround the items with double quotes to make stringsComplete command:
mr{[mi[s:<enter>r,t,;vgsms[lems"
Output:
Beta Was this translation helpful? Give feedback.
All reactions