'Extend current selection to complete lines'

def extend_selection_to_complete_lines(self):

    cursor = self.textCursor()
    (start_pos, end_pos) = (cursor.selectionStart(), cursor.selectionEnd())
    cursor.setPosition(start_pos)
    cursor.setPosition(end_pos, QTextCursor.KeepAnchor)
    if cursor.atBlockStart():
        cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.KeepAnchor)
        cursor.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
    self.setTextCursor(cursor)
