| Replaces every given pattern occurrences in the document with the replacement pattern.

        .. warning::

            Initializing **wrap_around** keyword to **True** leads to infinite recursion loop
            if the search pattern and the replacement_pattern are the same.

        :param pattern: Pattern to replace.
        :type pattern: unicode
        :param replacement_pattern: Replacement pattern.
        :type replacement_pattern: unicode
        :param \*\*kwargs: Format settings.
        :type \*\*kwargs: dict
        :return: Method success.
        :rtype: bool

def replace_all(self, pattern, replacement_pattern, **kwargs):
        """
        | Replaces every given pattern occurrences in the document with the replacement pattern.

        .. warning::

            Initializing **wrap_around** keyword to **True** leads to infinite recursion loop
            if the search pattern and the replacement_pattern are the same.

        :param pattern: Pattern to replace.
        :type pattern: unicode
        :param replacement_pattern: Replacement pattern.
        :type replacement_pattern: unicode
        :param \*\*kwargs: Format settings.
        :type \*\*kwargs: dict
        :return: Method success.
        :rtype: bool
        """

        edit_cursor = self.textCursor()

        edit_cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor)
        self.setTextCursor(edit_cursor)

        patterns_replaced = []
        while True:
            if not self.search(pattern, **kwargs):
                break

            cursor = self.textCursor()
            metrics = self.get_selected_text_metrics()
            if cursor.isNull():
                break

            if not cursor.hasSelection():
                break
            cursor.insertText(replacement_pattern)
            patterns_replaced.append(metrics)

        self.patterns_replaced.emit(patterns_replaced)

        return True