{"record":{"id":"b72875bb95d04906","repo":"helix-editor/helix","slug":"key-cannot-be-used-with-modifiers-use-in","errorCode":null,"errorMessage":"Key '-' cannot be used with modifiers, use '{}' instead","messagePattern":"Key '-' cannot be used with modifiers, use '(.+?)' instead","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-view/src/input.rs","lineNumber":410,"sourceCode":"            function if function.len() > 1 && function.starts_with('F') => {\n                let function: String = function.chars().skip(1).collect();\n                let function = str::parse::<u8>(&function)?;\n                (function > 0 && function < 25)\n                    .then_some(KeyCode::F(function))\n                    .ok_or_else(|| anyhow!(\"Invalid function key '{}'\", function))?\n            }\n            // Checking that the last token is empty ensures that this branch is only taken if\n            // `-` is used as a code. For example this branch will not be taken for `S-` (which is\n            // missing a code).\n            _ if s.ends_with('-') && tokens.last().is_some_and(|t| t.is_empty()) => {\n                if s == \"-\" {\n                    return Ok(KeyEvent {\n                        code: KeyCode::Char('-'),\n                        modifiers: KeyModifiers::empty(),\n                    });\n                } else {\n                    let suggestion = format!(\"{}-{}\", s.trim_end_matches('-'), keys::MINUS);\n                    return Err(anyhow!(\n                        \"Key '-' cannot be used with modifiers, use '{}' instead\",\n                        suggestion\n                    ));\n                }\n            }\n            invalid => return Err(anyhow!(\"Invalid key code '{}'\", invalid)),\n        };\n\n        let mut modifiers = KeyModifiers::empty();\n        for token in tokens {\n            let flag = match token {\n                \"S\" => KeyModifiers::SHIFT,\n                \"A\" => KeyModifiers::ALT,\n                \"C\" => KeyModifiers::CONTROL,\n                \"Meta\" | \"Cmd\" | \"Win\" => KeyModifiers::SUPER,\n                _ => return Err(anyhow!(\"Invalid key modifier '{}-'\", token)),\n            };\n","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-view/src/input.rs#L392-L428","documentation":"The '-' character is ambiguous because '-' is the modifier separator in key specs, so a bare trailing '-' code combined with modifiers (\"C--\") cannot be represented that way. FromStr detects a spec ending in '-' with an empty final token and, unless the whole spec is just \"-\", rejects it and suggests the special key name: \"{modifiers}-minus\".","triggerScenarios":"Keymap entries like \"C--\" or \"A--\" intending Ctrl+minus / Alt+minus; writing \"S--\" for shift-minus.","commonSituations":"Binding font-zoom-out or decrement actions to Ctrl/Alt+Minus; configs ported from formats that accept \"C--\" (Kakoune style) without translation.","solutions":["Replace the trailing '-' with the special key name: \"C--\" becomes \"C-minus\", \"A--\" becomes \"A-minus\".","A plain '-' with no modifiers is fine as-is and needs no change.","The error message itself prints the exact suggested binding — use it."],"exampleFix":"# before (config.toml)\n \"C--\" = \"decrease_font_size\"\n\n# after\n \"C-minus\" = \"decrease_font_size\"","handlingStrategy":"validation","validationCode":"fn normalize_minus(spec: &str) -> String {\n    if spec.len() > 1 && spec.ends_with('-') {\n        format!(\"{}minus\", spec)\n    } else {\n        spec.to_string()\n    }\n}\n\nlet ev = normalize_minus(spec).parse::<KeyEvent>()?;","typeGuard":null,"tryCatchPattern":"if let Err(err) = spec.parse::<KeyEvent>() {\n    let msg = err.to_string();\n    if msg.contains(\"cannot be used with modifiers\") {\n        // message already contains the corrected binding, e.g. \"use 'C-minus' instead\"\n        return Err(anyhow!(\"{msg} (from spec '{spec}')\"));\n    }\n    return Err(err);\n}","preventionTips":["Always spell modifier+minus as \"{MOD}-minus\".","Run a config lint pass that rewrites trailing '-' codes to minus.","Note plain '-' alone is valid; only combined forms are rejected."],"tags":["keymap","input","helix","rust"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}