If from the current cursor to last linebreak are all space, then
remove all those spaces and the last line break
342384
public void removeSpaceToLastLineBreak(IContext ctx) {
        boolean shouldRemoveSpace = true;
        List<Token> bl = builders();
        for (int i = bl.size() - 1; i >= 0; --i) {
            TextBuilder tb = bl.get(i);
            if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) {
                continue;
            }
            if (tb.getClass().equals(Token.StringToken.class)) {
                String s = tb.toString();
                if (s.matches("[ \\t\\x0B\\f]+")) {
                    continue;
                } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) {
                } else {
                    shouldRemoveSpace = false;
                }
            }
            break;
        }
        if (shouldRemoveSpace) {
            for (int i = bl.size() - 1; i >= 0; --i) {
                TextBuilder tb = bl.get(i);
                if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) {
                    continue;
                }
                if (tb.getClass().equals(Token.StringToken.class)) {
                    String s = tb.toString();
                    if (s.matches("[ \\t\\x0B\\f]+")) {
                        bl.remove(i);
                        continue;
                    } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) {
                        bl.remove(i);
                    }
                }
                break;
            }
        }
    }
1237486
function insertFormattedLineBreak(cursor) {
	const indent = cursor.editor.getTabText();
	const lineIndent = getLineIndent(cursor);

	cursor.selection.insertText(`\n${lineIndent}${indent}\n${lineIndent}`, { autoIndent: false });

	// Put caret at the end of indented newline
	cursor.moveUp();
	cursor.moveToEndOfLine();
}
1043904
def end_of_line(event):
    "  "
    buff = event.current_buffer
    buff.cursor_position += buff.document.get_end_of_line_position()
1245236
def erase_end_of_line (self): # <ESC>[0K -or- <ESC>[K
        ''''''

        self.fill_region (self.cur_r, self.cur_c, self.cur_r, self.cols)
78374
def handle_whitespace(text):
    
    """
    text = re_retab.sub(sub_retab, text)
    text = re_whitespace.sub('', text).strip()
    return text
1333232
public function lineBreak()
    {
        echo $this->color->__invoke(str_repeat('─', $this->terminal->getWidth()))->yellow();
    }
886936
def unix_line_discard(event):
    
    buff = event.current_buffer

    if buff.document.cursor_position_col == 0 and buff.document.cursor_position > 0:
        buff.delete_before_cursor(count=1)
    else:
        deleted = buff.delete_before_cursor(count=-buff.document.get_start_of_line_position())
        event.cli.clipboard.set_text(deleted)
593288
private boolean skipWhitespace() {
    boolean foundLineTerminator = false;
    while (!isAtEnd() && peekWhitespace()) {
      if (isLineTerminator(nextChar())) {
        foundLineTerminator = true;
      }
    }
    return foundLineTerminator;
  }
1211180
function(cm, operatorArgs, _vim, curStart, curEnd) {
        // If the ending line is past the last line, inclusive, instead of
        // including the trailing \n, include the \n before the starting line
        if (operatorArgs.linewise &&
            curEnd.line > cm.lastLine() && curStart.line > cm.firstLine()) {
          curStart.line--;
          curStart.ch = lineLength(cm, curStart.line);
        }
        vimGlobalState.registerController.pushText(
            operatorArgs.registerName, 'delete', cm.getRange(curStart, curEnd),
            operatorArgs.linewise);
        cm.replaceRange('', curStart, curEnd);
        if (operatorArgs.linewise) {
          cm.setCursor(motions.moveToFirstNonWhiteSpaceCharacter(cm));
        } else {
          cm.setCursor(curStart);
        }
      }
977395
def split_trailing_indent(line, max_indents=None):
    """"""
    indent = ""
    while (
        (max_indents is None or max_indents > 0)
        and line.endswith((openindent, closeindent))
    ) or line.rstrip() != line:
        if max_indents is not None and (line.endswith(openindent) or line.endswith(closeindent)):
            max_indents -= 1
        indent = line[-1] + indent
        line = line[:-1]
    return line, indent
1174286
function cleanseText( options, cb ) {
  return function( error, text ) {
    if ( !error ) {
      // clean up text
      text = util.replaceBadCharacters( text );

      if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) {
        if ( options.preserveOnlyMultipleLineBreaks ) {
          text = text.replace( STRIP_ONLY_SINGLE_LINEBREAKS, '$1 ' ).trim();
        }
        text = text.replace( WHITELIST_PRESERVE_LINEBREAKS, ' ' );
      } else {
        text = text.replace( WHITELIST_STRIP_LINEBREAKS, ' ' );
      }

      // multiple spaces, tabs, vertical tabs, non-breaking space]
      text = text.replace( / (?! )/g, '' )
        .replace( /[ \t\v\u00A0]{2,}/g, ' ' );

      text = entities.decode( text );
    }
    cb( error, text );
  };
}
855876
function(editor) {
			if (!this.insertLineBreakOnlyAction(editor)) {
				var curPadding = editorUtils.getCurrentLinePadding(editor);
				var content = String(editor.getContent());
				var caretPos = editor.getCaretPos();
				var len = content.length;
				var nl = '\n';
					
				// check out next line padding
				var lineRange = editor.getCurrentLineRange();
				var nextPadding = '';
					
				for (var i = lineRange.end, ch; i < len; i++) {
					ch = content.charAt(i);
					if (ch == ' ' || ch == '\t')
						nextPadding += ch;
					else
						break;
				}
				
				if (nextPadding.length > curPadding.length) {
					editor.replaceContent(nl + nextPadding, caretPos, caretPos, true);
				} else {
					editor.replaceContent(nl, caretPos);
				}
			}
			
			return true;
		}
955808
private void skipEmptyLines() {
		int tmp = index;
		do {
			tmp = skipLineSpace(tmp);
			if (tmp < tokens.size() && tokens.get(tmp).kind != Token.Kind.NewLine) {
				return; // done
			} else if (tmp >= tokens.size()) {
				index = tmp;
				return; // end-of-file reached
			}
			// otherwise, skip newline and continue
			tmp = tmp + 1;
			index = tmp;
		} while (true);
		// deadcode
	}
156945
def _erase_in_line(self, value):
        
        initial_pos = self._cursor.position()
        if value == 0:
            # delete end of line
            self._cursor.movePosition(self._cursor.EndOfBlock, self._cursor.KeepAnchor)
        elif value == 1:
            # delete start of line
            self._cursor.movePosition(self._cursor.StartOfBlock, self._cursor.KeepAnchor)
        else:
            # delete whole line
            self._cursor.movePosition(self._cursor.StartOfBlock)
            self._cursor.movePosition(self._cursor.EndOfBlock, self._cursor.KeepAnchor)
        self._cursor.insertText(' ' * len(self._cursor.selectedText()))
        self._cursor.setPosition(initial_pos)
        self._text_edit.setTextCursor(self._cursor)
        self._last_cursor_pos = self._cursor.position()
322893
def erase_start_of_line (self): # <ESC>[1K
        ''''''

        self.fill_region (self.cur_r, 1, self.cur_r, self.cur_c)
445485
def join_selected_lines(self, separator=' '):
        
        assert self.selection_state

        # Get lines.
        from_, to = sorted([self.cursor_position, self.selection_state.original_cursor_position])

        before = self.text[:from_]
        lines = self.text[from_:to].splitlines()
        after = self.text[to:]

        # Replace leading spaces with just one space.
        lines = [l.lstrip(' ') + separator for l in lines]

        # Set new document.
        self.document = Document(text=before + ''.join(lines) + after,
                                 cursor_position=len(before + ''.join(lines[:-1])) - 1)
403153
function trimLeadingLineBreaks(node) {
          do {
            if (node.nodeType === 3) {
              node.nodeValue = node.nodeValue.replace(/^[\r\n]+/, '');
            }

            node = node.firstChild;
          } while (node);
        }