Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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
  1. web selects the second word without whitespace
  2. S splits the selection on regex match. We type in _to_ for the regex and hit <enter> to split it into two sections
  3. <alt-(> rotates the contents of the selections
  4. Pressing Q for the first time begins recording a macro
  5. x selects the whole line
  6. t, selects until (but not including) the next comma
  7. S splits the whole line on regex match. We type in = for the regex and hit <enter> to split it into two sections
  8. _ trims trailing whitespace on all selections
  9. <alt-(> rotates the contents of the selections
  10. Pressing Q for the second time ends the recording of the macro
  11. 6q repeats the recorded macro sequence 6 times