OK, I think the following works. Anyone who uses the MMD bundle, please try it out in various circumstances. My testing indicates that it works, but I may have missed something.
If I don't hear of any bugs, I'll update the bundle on my web site....
Replace the command for "List - New Sibling" with:
#!/usr/bin/env perl
# New, cleaned up, improved list sibling command # Thanks to Allan Odgaard and Brian H for finding and # helping to fix problem with special characters in list items
# get current line, and break into what is left and right of caret
$line = $ENV{'TM_CURRENT_LINE'};
$index = $ENV{'TM_LINE_INDEX'}; $line =~ /^(.{$index})(.*)$/; $left = $1; $right = $2;
# Escape special characters since we will paste as snippet $left =~ s/(?=[$`\])/\/g; $right =~ s/(?=[$`\])/\/g;
# Now, figure out what to paste back
if ($left =~ /^\s*((*|+|-|\d+.)\s*)\S+/) { # We appear to have a list item with content, so create a new sibling $marker = $1; # What was used as a list item marker? # If the marker included a counter, increment it $marker =~ s{ (\d+) }{ $1+1; }ex; print "$left\n$marker$right$0"; } else { # Not a list item with content, so strip marker (if any) and add a newline $left =~ s/^\s*((*|+|-|\d+.)\s*)//; print "$left\n$right$0"; }