Skip to main content
Commonmark migration
Source Link

V 14 12 bytes

#V 14 12 bytes ThanksThanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

This just translates to :%s/\v(-)=[^0].*/\11 which matches one or more - followed by anything but 0, followed by anything any number of times. It's replaced with the first match (so either a - or nothing) and a 1. The regex doesn't match 0, so that stays itself.

The More Fun Way (21 bytes)

é
Àé12|DkJòhé-òó^$/a

TryItOnline

This accepts the input as an argument rather than in the buffer.

é<CR> Insert a new line.

À run the argument as V code. a - will move the cursor to the previous line, and any number will become the count for the next command

é1 insert (count)1's

2| move to the second column

D delete everything from the second column onwards (leaving only one character)

kJ Join the two lines together.

òhé-ò translates to: "run hé- until breaking". If the 1 was on the second line, this breaks immediately after the h. If it was on the first line, it will insert a - before breaking.

ó^$/a This fixes the fact that -1,0,1 will leave a blank, and replaces a blank with the argument register.

#V 14 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

This just translates to :%s/\v(-)=[^0].*/\11 which matches one or more - followed by anything but 0, followed by anything any number of times. It's replaced with the first match (so either a - or nothing) and a 1. The regex doesn't match 0, so that stays itself.

The More Fun Way (21 bytes)

é
Àé12|DkJòhé-òó^$/a

TryItOnline

This accepts the input as an argument rather than in the buffer.

é<CR> Insert a new line.

À run the argument as V code. a - will move the cursor to the previous line, and any number will become the count for the next command

é1 insert (count)1's

2| move to the second column

D delete everything from the second column onwards (leaving only one character)

kJ Join the two lines together.

òhé-ò translates to: "run hé- until breaking". If the 1 was on the second line, this breaks immediately after the h. If it was on the first line, it will insert a - before breaking.

ó^$/a This fixes the fact that -1,0,1 will leave a blank, and replaces a blank with the argument register.

V 14 12 bytes

Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

This just translates to :%s/\v(-)=[^0].*/\11 which matches one or more - followed by anything but 0, followed by anything any number of times. It's replaced with the first match (so either a - or nothing) and a 1. The regex doesn't match 0, so that stays itself.

The More Fun Way (21 bytes)

é
Àé12|DkJòhé-òó^$/a

TryItOnline

This accepts the input as an argument rather than in the buffer.

é<CR> Insert a new line.

À run the argument as V code. a - will move the cursor to the previous line, and any number will become the count for the next command

é1 insert (count)1's

2| move to the second column

D delete everything from the second column onwards (leaving only one character)

kJ Join the two lines together.

òhé-ò translates to: "run hé- until breaking". If the 1 was on the second line, this breaks immediately after the h. If it was on the first line, it will insert a - before breaking.

ó^$/a This fixes the fact that -1,0,1 will leave a blank, and replaces a blank with the argument register.

added 1188 characters in body
Source Link
nmjcman101
  • 3.7k
  • 10
  • 18

#V 14 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

This just translates to :%s/\v(-)=[^0].*/\11 which matches one or more - followed by anything but 0, followed by anything any number of times. It's replaced with the first match (so either a - or nothing) and a 1. The regex doesn't match 0, so that stays itself.

The More Fun Way (21 bytes)

é
Àé12|DkJòhé-òó^$/a

TryItOnline

This accepts the input as an argument rather than in the buffer.

é<CR> Insert a new line.

À run the argument as V code. a - will move the cursor to the previous line, and any number will become the count for the next command

é1 insert (count)1's

2| move to the second column

D delete everything from the second column onwards (leaving only one character)

kJ Join the two lines together.

òhé-ò translates to: "run hé- until breaking". If the 1 was on the second line, this breaks immediately after the h. If it was on the first line, it will insert a - before breaking.

ó^$/a This fixes the fact that -1,0,1 will leave a blank, and replaces a blank with the argument register.

#V 14 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

#V 14 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

This just translates to :%s/\v(-)=[^0].*/\11 which matches one or more - followed by anything but 0, followed by anything any number of times. It's replaced with the first match (so either a - or nothing) and a 1. The regex doesn't match 0, so that stays itself.

The More Fun Way (21 bytes)

é
Àé12|DkJòhé-òó^$/a

TryItOnline

This accepts the input as an argument rather than in the buffer.

é<CR> Insert a new line.

À run the argument as V code. a - will move the cursor to the previous line, and any number will become the count for the next command

é1 insert (count)1's

2| move to the second column

D delete everything from the second column onwards (leaving only one character)

kJ Join the two lines together.

òhé-ò translates to: "run hé- until breaking". If the 1 was on the second line, this breaks immediately after the h. If it was on the first line, it will insert a - before breaking.

ó^$/a This fixes the fact that -1,0,1 will leave a blank, and replaces a blank with the argument register.

added 19 characters in body
Source Link
nmjcman101
  • 3.7k
  • 10
  • 18

#V 1414 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a WAY more fun function that's less bytes, but it's not working the way I expected.

ͨ-©½[^0].*©½0]/±1

Verify Test CasesVerify Test Cases

#V 14 bytes Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a WAY more fun function that's less bytes, but it's not working the way I expected.

ͨ-©½[^0].*/±1

Verify Test Cases

#V 14 12 bytes Thanks @DJMcMayhem for 2 bytes. Uses a reg-ex to do the substitution. Kind of fun, because it's not a built-in. I have a more fun function, but it's not working the way I expected.

ͨ-©½0]/±1

Verify Test Cases

Source Link
nmjcman101
  • 3.7k
  • 10
  • 18
Loading