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

Reverse Golf Example

Switch the "Before" and "After" cases for a Helix Golf example.

Before

# snake_case to camelCase

Rename all fields to be camelCase.

## Before

```js
const user_profile = {first_name: "John"};
```

## After

```js
const userProfile = {firstName: "John"};
```

After

# camelCase to snake_case

Rename all fields to be snake_case.

## Before

```js
const userProfile = {firstName: "John"};
```

## After

```js
const user_profile = {first_name: "John"};
```

Preview

Command

ebyxb*Rv""Nn<alt-)>

%s`+j<enter>f;<alt-(>
  1. eb selects the next word and trims whitespace
  2. y copies the selected word and yanks it into the " (double quote) register
  3. xb selects the last word in the line
  4. * sets the current selection as the search pattern
  5. R replaces the selected word with the copied selection from earlier
  6. v enters select mode
  7. "" selects the " (double quote) register. Pressing N will add a new selection at the previous occurrence of the word saved to the register
  8. n adds a new selection at the next occurrence of the search pattern assigned earlier
  9. <alt-)> rotates the contents of the selections forward
  10. % selects the entire contents of the file
  11. s brings up a prompt to select sub-selections by a given regex. We type in `+j for the regex and select all matches with <enter>
  12. Since we're still in select mode, typing f; moves each cursor to select up until (and including) the next occurrence of a semicolon
  13. <alt-(> rotates the contents of the selections backwards