def commit(self):
        """
        Insert the specified text in all selected lines, always
        at the same column position.
        """

        # Get the number of lines and columns in last line.
        last_line, last_col = self.qteWidget.getNumLinesAndColumns()

        # If this is the first ever call to this undo/redo element
        # then backup the current cursor- and marker position because
        # both will be required for the redo operation.
        if self.cursorPos is None:
            # Get the default marker and ensure it points to a
            # valid location inside the document.
            self.markerPos = self.qteWidget.qteGetMark()
            if self.markerPos is None:
                return
            if not self.qteWidget.isPositionValid(*self.markerPos):
                return

            # Backup the current cursor and marker position; swap
            # one for the other if necessary to ensure the marker
            # comes first.
            self.cursorPos = self.qteWidget.getCursorPosition()
            if self.cursorPos[0] < self.markerPos[0]:
                self.cursorPos, self.markerPos = self.markerPos, self.cursorPos

        # Shorthand for qteWidget and left/right position of rectangle.
        wid = self.qteWidget
        col1 = min((self.markerPos[1], self.cursorPos[1]))
        col2 = max((self.markerPos[1], self.cursorPos[1]))

        # Insert the specified string at the same position in every line
        # in between the mark and the cursor (inclusive).
        self.removedText = []
        for line in range(self.markerPos[0], self.cursorPos[0] + 1):
            text = wid.text(line)
            if col1 >= len(text):
                # If the line has no text in the specified column
                # range then ignore it.
                self.removedText.append('')
                continue
            if col2 > len(text):
                # If the col1-col2 range spans only part of the
                # line then select only that part.
                wid.setSelection(line, col1, line, col1)
                wid.SendScintilla(wid.SCI_LINEENDEXTEND, 0, 0)
            else:
                # If the col1-col2 range is a subset of the entire
                # line then select the entire range.
                wid.setSelection(line, col1, line, col2)

            # Backup and remove the selected text.
            self.removedText.append(self.qteWidget.selectedText())
            self.baseClass.removeSelectedText()

        self.qteWidget.setCursorPosition(self.cursorPos[0], self.markerPos[1])

        # Determine the user selected string length and initialise the global
        # variable qteKilledTextFromRectangle with an empty dictionary.
        strlen = col2 - col1
        global qteKilledTextFromRectangle
        qteKilledTextFromRectangle = []

        # Copy the removed text into the global variable
        # 'qteKilledTextFromRectangle' so that YankRectangle can
        # access it. However, ensure that every element has exactly
        # the length specified by the user defined rectangle; zero pad
        # elements that are too short. Note: do not apply this zero
        # padding to self.removedText because otherwise the text could
        # not be undone correctly.
        for el in self.removedText:
            # Determine how many white space characters are required
            # to make the string 'strLen' characters long.
            pad = strlen - len(el)

            # Sanity check.
            if pad < 0:
                qteKillTextFromRectangle = None
                self.qteWidget.setCursorPosition(*self.cursorPos)
                self.cursorPos = self.markerPos = None
                msg = 'Padding length cannot be negative --> this is a bug'
                self.qteLogger.error(msg)
                return

            # Store the padded version of the string.
            qteKilledTextFromRectangle.append(el + ' ' * pad)