code: def create_operator_decorator(registry):
      
      assert isinstance(registry, BaseRegistry)
  
      operator_given = ViWaitingForTextObjectMode()
      navigation_mode = ViNavigationMode()
      selection_mode = ViSelectionMode()
  
      def operator_decorator(*keys, **kw):
          """
          Register a Vi operator.
  
          Usage::
  
              @operator('d', filter=...)
              def handler(cli, text_object):
                  # Do something with the text object here.
          """
          filter = kw.pop('filter', Always())
          eager = kw.pop('eager', False)
          assert not kw
  
          def decorator(operator_func):
              @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
              def _(event):
                  """
                  Handle operator in navigation mode.
                  """
                  # When this key binding is matched, only set the operator
                  # function in the ViState. We should execute it after a text
                  # object has been received.
                  event.cli.vi_state.operator_func = operator_func
                  event.cli.vi_state.operator_arg = event.arg
  
              @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
              def _(event):
                  """
                  Handle operator in selection mode.
                  """
                  buff = event.current_buffer
                  selection_state = buff.selection_state
  
                  # Create text object from selection.
                  if selection_state.type == SelectionType.LINES:
                      text_obj_type = TextObjectType.LINEWISE
                  elif selection_state.type == SelectionType.BLOCK:
                      text_obj_type = TextObjectType.BLOCK
                  else:
                      text_obj_type = TextObjectType.INCLUSIVE
  
                  text_object = TextObject(
                      selection_state.original_cursor_position - buff.cursor_position,
                      type=text_obj_type)
  
                  # Execute operator.
                  operator_func(event, text_object)
  
                  # Quit selection mode.
                  buff.selection_state = None
  
              return operator_func
          return decorator
      return operator_decorator
docs: Create a decorator that can be used for registering Vi operators.