Skip to content

Instantly share code, notes, and snippets.

@ajmcmiddlin
Created January 20, 2023 00:35
Show Gist options
  • Save ajmcmiddlin/b0749f33f0f3b770c7a0d502f942f271 to your computer and use it in GitHub Desktop.
Save ajmcmiddlin/b0749f33f0f3b770c7a0d502f942f271 to your computer and use it in GitHub Desktop.
Numbering bullet points in helix editor

Here's a way to number bullet points in helix.

Let's start with a bulleted list.

- Item one
- Item two over
  two lines
- Item three

We can number this using the nl command line tool and replacing selections with the result of piping the selection to a shell command.

  1. Select all the text above.
  2. Press the | key, which is the primitive for piping a selection to a command and replacing the selection with its output.
  3. Use this command: nl -s. -w1 -bp^-.

The nl -s. -w1 -bp^- command does line numbering, with a '.' at the end of the number (-s.), no padding (-w1), and only on lines that start with a hyphen (-bp^-).

At this point you'll get the following.

1.- Item one
2.- Item two over
    two lines
3.- Item three

From here you can do the following to get rid of the unwanted hyphens and spaces.

  1. Select the block.
  2. Use the s primitive to select within the selection using a regex.
  3. Use the regex ^\d+\.- to select every line starting with numbers, a period, and a hyphen.
  4. Press ; to collapse each selection to a single cursor, which will be at the end of the selection (the hyphens).
  5. d to delete all the hyphens.

You might want to repeat the above, but using ^ as the regex to get rid of the extra space left at the beginning of subsequent lines on a multi-line list item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment