Skip to content

vscode extension - Cycle or increment/decrement values on the current line: targets the value under the cursor or jumps to the first match

License

Notifications You must be signed in to change notification settings

metaory/smart-value-toggle

logo

value-cycle

demo

Cycle or nudge values on the line (at cursor or first match) or in the selection. No default keybindings.

Rule types

Rules are tried in order; the first matching type wins.

Type Description Options
boolean falsetrue
operatorPair Toggle between two strings pair: [string, string] e.g. ["&&", "||"]
nary Integers in base 2–36 base (default 10)
fraction Decimal numbers step (optional; inferred from decimal places if omitted: 0.1, 0.01, …)
letters Single letter a–z / A–Z
hexColor #rgb or #rrggbb
semver x.y.z bump segment segment: "major" | "minor" | "patch"
quote Toggle '…'"…" (escape/unescape inner)
constants Cycle through a list list: string[]

Default value-cycle.rules order: boolean → operatorPair → nary → fraction → letters → hexColor → semver → quote (constants available but not in the default list).

Settings

  • value-cycle.rules – Array of { type, options?, when?: { languageId?, visualOnly? } }. Defines which types are active and in what order.
  • value-cycle.disabledTypes – Array of type names to disable (e.g. ["constants"]). Types in this list are removed from the effective rules. Lets you turn off a type without editing the full rules array.

Keybindings

No keybindings are contributed. Add in Keyboard Shortcuts (JSON):

  • Increment: value-cycle.cycle with args: { "direction": "increment", "count": 1 }
  • Decrement: args: { "direction": "decrement", "count": 1 }
  • With count: e.g. "count": 5
  • Global (all matches in highlighted range): args: { "direction": "increment", "global": true }

Example:

[
  { "key": "ctrl+a", "command": "value-cycle.cycle", "args": { "direction": "increment" }, "when": "editorTextFocus" },
  { "key": "ctrl+x", "command": "value-cycle.cycle", "args": { "direction": "decrement" }, "when": "editorTextFocus" }
]

Behavior

  • Current line (no highlight): target the value under the cursor, or the first match on the line. When multiple matches overlap (e.g. "true"), the innermost match wins so the inner type (boolean, nary, etc.) applies. After edit, cursor moves to the start of the edited match only when you “jumped” to it (not when the match was under the cursor).
  • Highlighted text: operate on the highlighted range; with global: true, all rule matches inside that range are updated (innermost matches only when overlapping).

Acknowledgement

Inspired by dial.nvim. Neovim had it; we missed it in VS Code, so here it is.

License

MIT

About

vscode extension - Cycle or increment/decrement values on the current line: targets the value under the cursor or jumps to the first match

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors