             onEnter:
                 keepDefault: false
                 replaceWith: (data) =>
-                    lines = data.textarea.value[0..(data.caretPosition - 1)].split("\n")
-                    lastLine = lines[lines.length - 1]
+                    lines = data.textarea.value.split("\n")
+                    cursorLine = data.textarea.value[0..(data.caretPosition - 1)].split("\n").length
+                    newLineContent = data.textarea.value[data.caretPosition..].split("\n")[0]
+                    lastLine = lines[cursorLine - 1]
 
                     # unordered list -
                     match = lastLine.match /^(\s*- ).*/
+
                     if match
                         emptyListItem = lastLine.match /^(\s*)\-\s$/
 
                         if emptyListItem
                             markdownCaretPositon = removeEmptyLine(data.textarea, lines.length - 1, data.caretPosition)
                         else
-                            return "\n#{match[1]}" if match
+                            breakLineAtBeginning = newLineContent.match /^(\s*)\-\s/
+
+                            if !breakLineAtBeginning
+                                return "\n#{match[1]}" if match
 
                     # unordered list *
                     match = lastLine.match /^(\s*\* ).*/

                        if emptyListItem
                            markdownCaretPositon = removeEmptyLine(data.textarea, lines.length - 1, data.caretPosition)
                        else
                            return "\n#{match[1]}" if match

                    # ordered list
                    match = lastLine.match /^(\s*)(\d+)\.\s/

                        if emptyListItem
                            markdownCaretPositon = removeEmptyLine(data.textarea, lines.length - 1, data.caretPosition)
                        else
                            breakLineAtBeginning = newLineContent.match /^(\s*)(\d+)\.\s/

                            if !breakLineAtBeginning
                                return "\n#{match[1] + (parseInt(match[2], 10) + 1)}. "

                    return "\n"

