cyclechr
Cycle through a list of candidate strings every time you press a key.
Example: pressing = repeatedly cycles = → = → == → === → back to =.
English | 日本語
English
Features
- Press a key repeatedly to cycle the text immediately before the cursor through a list
of candidates.
- Works with multiple cursors — every selection is cycled independently, applied as a
single edit.
- A key with no matching rule falls back to normal typing, so keys you haven't
configured are unaffected.
- Candidate lists can be scoped per language ID, or shared across all languages with
*.
Keys enabled out of the box
| Key |
Default candidates |
= |
= → = → == → === |
- |
- → -- → -> |
> (Shift+.) |
> → >= → >> → => |
How it works
cyclechr binds specific keys to its own cyclechr.type command, instead of overriding
VS Code's built-in type command. This avoids conflicts with other extensions that rely
on type, such as Vim emulation extensions.
When you press a bound key:
- cyclechr looks up the candidate list for that key — first under the current file's
language ID, then under
* (all languages).
- If the text immediately before the cursor ends with one of the candidates, it's
replaced with the next candidate in the list (wrapping around to the first candidate
after the last one).
- If it doesn't match any candidate, the first candidate is inserted.
- If there's no rule for that key at all, cyclechr forwards the keystroke to VS Code's
normal typing command, so the key behaves as if cyclechr weren't installed.
Extension Settings
This extension contributes the cyclechr.rules setting.
"cyclechr.rules": {
"*": {
"=": ["=", " = ", " == ", " === "],
"-": ["-", "--", "->"]
},
"typescript": {
"=": ["=", " = ", " === ", " == "]
}
}
- Top-level keys are language IDs (
typescript, javascript, go, ...). Use "*" for
all languages.
- Each language entry maps a key (the character a keybinding sends, e.g.
"=", ">")
to an ordered list of candidate strings.
- Setting
cyclechr.rules replaces the built-in default entirely — it is not merged
key by key or language by language. If you only want to add one language or key,
copy the defaults you want to keep alongside your addition.
Adding a key that isn't bound yet
To use a symbol that isn't in the table above:
Add a keybinding in your own keybindings.json (Command Palette → "Preferences: Open
Keyboard Shortcuts (JSON)"):
{
"key": "shift+7", // the physical key combination, not the character — see Known Issues
"command": "cyclechr.type",
"args": { "key": "&" },
"when": "editorTextFocus && !editorReadonly"
}
Add candidates for that key in cyclechr.rules (see above).
Both steps are needed: the keybinding decides when cyclechr.type runs, and
cyclechr.rules decides what it does. If a keybinding calls cyclechr.type without
args.key — for example one added through the Keyboard Shortcuts UI, which doesn't let
you set command arguments — cyclechr can't tell which key was pressed, so it shows a
warning instead of silently doing nothing.
Known Issues
- VS Code keybinding
key values must match the physical key combination, not the
character it produces. Shifted symbols need a shift+ prefix (e.g. > is
shift+., not >), and the exact combination can differ across keyboard layouts.
- The Keyboard Shortcuts UI can bind a key to
cyclechr.type, but it can't set command
arguments — a binding added or changed that way needs args added by hand in
keybindings.json, or the key won't type anything.
cyclechr.rules does not merge with the built-in default per key or per language —
setting it replaces the whole value.
- Candidates inside strings or comments are not excluded yet; cycling is purely
text-based.
日本語
特徴
- キーを繰り返し押すことで、カーソル直前のテキストを候補リストの次の候補へ切り替える。
- マルチカーソルに対応。全カーソル分の判定を、1 回の編集としてまとめて適用する。
- 対応ルールの無いキーは、通常の文字入力にそのまま戻る。設定していないキーには影響しない。
- 候補リストは、言語 ID ごとに分けたり、
* で全言語共通にしたりできる。
最初から使えるキー
| キー |
初期候補 |
= |
= → = → == → === |
- |
- → -- → -> |
>(Shift+.) |
> → >= → >> → => |
仕組み
cyclechr は、VS Code 標準の type コマンドを上書きするのではなく、特定のキーだけを独自の
cyclechr.type コマンドに割り当てています。これにより、type を使う他の拡張機能(Vim エミ
ュレーション拡張など)との衝突を避けています。
割り当てたキーを押すと、次の順で処理されます。
- そのキーの候補リストを、まず現在のファイルの言語 ID の設定から、無ければ
*(全言語共通)
の設定から探す。
- カーソル直前のテキストが、候補のいずれかで終わっていれば、その候補をリストの次の候補に
置き換える(最後の候補の次は先頭に戻る)。
- どの候補にも一致しなければ、先頭の候補を新規に挿入する。
- そのキーの候補設定が無ければ、通常の文字入力コマンドにそのまま渡し、cyclechr が入って
いないときと同じ動作にする。
拡張機能の設定
この拡張機能は、設定 cyclechr.rules を提供します。
"cyclechr.rules": {
"*": {
"=": ["=", " = ", " == ", " === "],
"-": ["-", "--", "->"]
},
"typescript": {
"=": ["=", " = ", " === ", " == "]
}
}
- トップレベルのキーは言語 ID(
typescript、javascript、go など)。全言語共通にしたい
場合は "*" を使う。
- 各言語の設定は、キー(キーバインドが渡す文字。例:
"="、">")から、候補文字列の配列への
対応表になっている。
cyclechr.rules を設定すると、内蔵の初期値は丸ごと置き換わります(キー単位・言語単位で
マージされません)。 一部の言語やキーだけ追加したい場合は、残したい初期値も一緒に書いて
ください。
まだ割り当てられていないキーを追加する
上の表に無い記号を使いたい場合は、次の手順が必要です。
自分の keybindings.json(コマンドパレット →「基本設定: キーボード ショートカットを開く
(JSON)」)に、キーバインドを追加する。
{
"key": "shift+7", // 実際に押す物理キーの組み合わせ。文字そのものではない点に注意(下記「既知の問題」参照)
"command": "cyclechr.type",
"args": { "key": "&" },
"when": "editorTextFocus && !editorReadonly"
}
cyclechr.rules に、そのキーの候補を追加する(上記参照)。
どちらも必要です。キーバインドは「いつ cyclechr.type を実行するか」を決め、
cyclechr.rules は「実行したときに何をするか」を決めます。キーボード ショートカット画面
(GUI)から追加・変更した場合など、args.key が無い状態で cyclechr.type が呼ばれると、
どのキーが押されたか分からないため、黙って何もしない代わりに警告を表示します。
既知の問題
- VS Code のキーバインドの
key は、入力される文字ではなく、実際に押す物理キーの組み合わせ
で書く必要があります。Shift が必要な記号は shift+ を付ける必要があり(例: > は > では
なく shift+.)、キーボード配列によって組み合わせが変わることがあります。
- キーボード ショートカット画面(GUI)から
cyclechr.type にキーを割り当てたり変更したりで
きますが、コマンド引数(args)は設定できません。GUI で追加・変更したキーバインドは、
keybindings.json で手動で args を追加しないと、そのキーで何も入力されなくなります。
cyclechr.rules は、キー単位・言語単位で内蔵の初期値とマージされません。設定すると、値
全体が置き換わります。
- 文字列やコメントの中の候補を除外する機能は、まだありません。判定は純粋にテキストベースで
行われます。
Based on the design of smartchr.el.