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
webselects the second word without whitespaceSsplits 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
Qfor the first time begins recording a macro xselects the whole linet,selects until (but not including) the next commaSsplits 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
Qfor the second time ends the recording of the macro 6qrepeats the recorded macro sequence 6 times