code: def _paint_margins(self, event):
          
          font = QtGui.QFont(self.editor.font_name, self.editor.font_size +
                             self.editor.zoom_level)
          metrics = QtGui.QFontMetricsF(font)
          painter = QtGui.QPainter(self.editor.viewport())
          for pos, pen in zip(self._positions, self._pens):
              if pos < 0:
                  # margin not visible
                  continue
              offset = self.editor.contentOffset().x() + \
                  self.editor.document().documentMargin()
              x_pos = round(metrics.width(' ') * pos) + offset
              painter.setPen(pen)
              painter.drawLine(x_pos, 0, x_pos, 2 ** 16)
docs: Paints the right margin after editor paint event.