anchor.diff:          ++ [ "# UI options" ]
           ++ optional (ui != null) "set-option global ui_options ${uiOptions}"
   
  -        ++ [ "# Key mappings" ] ++ map keyMappingString keyMappings
  +        ++ [ "# User modes" ] ++ userModeStrings ++ [ "# Key mappings" ]
  +        ++ map keyMappingString keyMappings
   
           ++ [ "# Hooks" ] ++ map hookString hooks);
     in pkgs.writeText "kakrc"
  
positive.code:   keyMapping = types.submodule {
      options = {
        mode = mkOption {
          type = types.enum [
            "insert"
            "normal"
            "prompt"
            "menu"
            "user"
            "goto"
            "view"
            "object"
          ];
          example = "user";
          description = ''
            The mode in which the mapping takes effect.
  
negative.code:           if useBuiltinKeyParser then "true" else "false"
          }"
        ];
  
      userModeString = mode:
        optionalString (!builtins.elem mode [
          "insert"
          "normal"
          "prompt"
          "menu"
          "user"
          "goto"
          "view"
          "object"
        ]) "try %{declare-user-mode ${mode}}";
  
      userModeStrings = map userModeString
        (lists.unique (map (km: km.mode) cfg.config.keyMappings));
  
      keyMappingString = km:
        concatStringsSep " " [
  