Overview
Introduction
JavaScript developers reach for Array.prototype.splice constantly to remove and replace a run of array elements in one call, but doing the same thing to a pasted text list usually means manual counting and retyping.
List Splicer brings splice's exact remove-and-insert semantics to a plain-text list, no code required.
What Is List Splicer?
A tool that removes a specified number of consecutive items starting at a given index and optionally inserts new items at that same spot, mirroring JavaScript's Array.prototype.splice precisely.
It supports negative start indices (counting from the end, just like splice) and shows both the resulting list and the removed items.
How List Splicer Works
The input is split into items on the resolved separator, and any replacement text is split the same way to produce the items to insert.
A single Array.prototype.splice(start, deleteCount, ...insertItems) call performs the removal and insertion; both the mutated array and its return value (the removed items) are captured and shown separately.
When To Use List Splicer
Use it to replace a run of consecutive items in a list, say, swapping items 3-5 for two different items, in one operation.
It's also useful whenever you specifically need JavaScript splice's exact index behavior, including negative start indices, reproduced on plain text.
Often used alongside List Editor, Sublist Extractor and List Slicer.
Features
Advantages
- Matches JavaScript's native splice behavior exactly, including negative-index support, so results are fully predictable for developers.
- Handles both removal and insertion in a single pass, no need to chain a separate delete and insert operation.
- Shows the removed items explicitly, so you can confirm nothing important was accidentally cut.
Limitations
- Replacement items are parsed using the same separator as the main list, so a replacement value containing that separator will be split into multiple items rather than kept intact.
- Delete count must be zero or positive; there's no shorthand for "delete everything from here to the end" (use a very large delete count instead).
Examples
Best Practices & Notes
Best Practices
- Use List Editor instead if you only need to touch a single item, splice is overkill for a one-item change.
- Double-check the delete count when using a negative start, it's easy to remove more or fewer items than intended near the end of the list.
Developer Notes
Implemented as a direct pass-through to Array.prototype.splice(start, deleteCount, ...insertItems) on a copy of the split items array, so all of splice's native index-clamping and negative-index behavior is inherited for free rather than reimplemented.
List Splicer Use Cases
- Swapping a run of consecutive configuration values for a different set in one operation
- Removing the last N items of a list using a negative start index
- Reproducing exact JavaScript splice behavior on a plain-text list for testing or teaching purposes
Common Mistakes
- Forgetting delete count is required even for a pure insert; pass 0 to insert without removing anything.
- Assuming replacement text with the list's separator inside it stays as one item; it gets split like everything else.
- Confusing 0-based splice indices with the 1-based indices used elsewhere in the List category (like List Editor and Sublist Extractor).
Tips
- Set delete count to 0 to use this purely as a multi-item insert tool.
- Use a very large delete count (like 9999) to mean "remove everything from here to the end."