Home Download Buy Blog Forum Support

Markdown Lists: Bullets don't auto-add on enter

Markdown Lists: Bullets don't auto-add on enter

Postby cgenco on Sat Mar 31, 2012 7:08 am

In TextMate, when making a bulleted list, hitting enter automatically inserts "* " on the next line. Hitting enter again removes the "* " for the current line and inserts another newline.

Sublime Text 2 doesn't do this, though seems to be using the same markdown bundle, and I can't figure out why. It's driving me crazy having to hit type all the extra "* " while taking notes in class. This is literally the last feature keeping me from switching to subl full time.

Example 1 (in TM, the pipe character | is the curser position):
Code: Select all
* this is my list|


Hit return:

Code: Select all
* this is my list
* |


Hit return again:

Code: Select all
* this is my list

|


Example 1b: same thing in Sublime Text 2

Code: Select all
* this is my list|


Hit return.

Code: Select all
* this is my list
|


:( Type "* " and waste precious seconds of your life.

Code: Select all
* this is my list
* |


Example 2: nested lists (in TM):

Code: Select all
* this is my list
  * subitem 1|


Hit return:

Code: Select all
* this is my list
  * subitem 1
  * |


Return again:

Code: Select all
* this is my list
  * subitem 1

|


Example 3: Ordered lists (in TM):

Code: Select all
1. First item|


Hit return:

Code: Select all
1. First item
2. |


-------------------------------------

Another smaller thing I could live without (but may be related) is that TM also auto-wraps headings. That is...

Code: Select all
# Heading 1|


Hit return.

Code: Select all
# Heading 1 #
|
cgenco
 
Posts: 1
Joined: Sat Mar 31, 2012 6:51 am

Re: Markdown Lists: Bullets don't auto-add on enter

Postby atomi on Sat Mar 31, 2012 11:21 pm

I have something similar in one of my packages

User/Markdown Add Line.sublime-macro
Code: Select all
[
    {"command": "move_to", "args": {"to": "hardeol"}},
    {"command": "insert", "args": {"characters": "\n"}},
    {"command": "insert", "args": {"characters": "*"}},
    {"command": "insert", "args": {"characters": " "}}
]

User/Markdown Delete Line.sublime-macro
Code: Select all
[
    {"command": "expand_selection", "args": {"to": "line"}},
    {"command": "add_to_kill_ring", "args": {"forward": true}},
    {"command": "left_delete"},
    {"command": "move", "args": {"by": "lines", "forward": false}},
    {"command": "move_to", "args": {"to": "hardeol"}}
]



User/Default.sublime-keymap
Code: Select all
    {
    "keys": ["enter"], "command": "run_macro_file", "args": {"file": "Packages/User/Markdown Add Line.sublime-macro"},
    "context": [ {"key": "selector", "operator": "equal", "operand": "markup.list.unnumbered.markdown", "match_all": true }]
    },
    {
    "keys": ["backspace"], "command": "run_macro_file",
    "args": {"file": "Packages/User/Markdown Delete Line.sublime-macro"},
    "context":
      [
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "\\*$", "match_all": true },
        { "key": "selector", "operator": "equal", "operand": "markup.list.unnumbered.markdown", "match_all": true }
      ]
    }


It might need some tweaking, but I'm sure you can figure out how to do the wrapping on your own.
It would seem like it would be something worth learning to do. The ordered list might need some plugin work but If you need help or you get it on your own post back and let everyone know :)
GL HTH
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Markdown Lists: Bullets don't auto-add on enter

Postby erinata on Mon Apr 02, 2012 12:20 am

https://github.com/erinata/SublimeMarkdown

You may try this.

The code is as bad as it can be because I never wrote python. But it add * - and > automatically in a markdown document.

I will add number list and other things later...........
erinata
 
Posts: 29
Joined: Wed Jan 25, 2012 12:19 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], karida and 31 guests