Invert Dictionary
Switch the key-value pairs of a dictionary.
Before
var color_to_points = {
"red" = 0,
"orange" = 5,
"yellow" = 10,
"green" = 15,
"blue" = 20,
"purple" = 30,
"black" = 50,
}
After
var points_to_color = {
0 = "red",
5 = "orange",
10 = "yellow",
15 = "green",
20 = "blue",
30 = "purple",
50 = "black",
}
Preview
Command
webS_to_<enter><alt-(>
Qxt,S=<enter>_<alt-(>Q6q
web
selects the second word without whitespaceS
splits the selection on regex match. We type in_to_
for the regex and hit<enter>
to split it into two sections<alt-(>
rotates the contents of the selections- Pressing
Q
for the first time begins recording a macro x
selects the whole linet,
selects until (but not including) the next commaS
splits the whole line on regex match. We type in=
for the regex and hit<enter>
to split it into two sections_
trims trailing whitespace on all selections<alt-(>
rotates the contents of the selections- Pressing
Q
for the second time ends the recording of the macro 6q
repeats the recorded macro sequence 6 times