How to Add Custom Phrases to custom_phrase.txt in RIME Wanxiang

To add custom phrases to custom_phrase.txt, open the file in a UTF-8 capable editor, append entries in the phrase<TAB>code<TAB>weight format, and redeploy the RIME schema.

The custom_phrase.txt file in the amzxyz/rime_wanxiang repository serves as a user dictionary that pins personalized phrases to the top of your candidate list. This plain-text file is loaded by the table_translator@custom_phrase component defined in [wanxiang.schema.yaml](https://github.com/amzxyz/rime_wanxiang/blob/wanxiang/wanxiang.schema.yaml), allowing you to map short input codes to full sentences, symbols, or dynamic date strings. Learning how to properly edit this file lets you customize your RIME input experience without modifying core schema files.

Understanding the custom_phrase.txt Format

The custom_phrase.txt file uses a strict three-column format separated by tab characters (\t):


<output phrase> <TAB> <input code> <TAB> <weight>

  • Output phrase: The text inserted when you select the candidate. This can include Unicode characters, emoji, or escaped sequences.
  • Input code: The keystrokes you type to trigger the phrase (e.g., nh for "你好世界").
  • Weight: An optional integer determining priority (higher values appear first; defaults to 5 if omitted).

The file header documents several escape sequences for embedding special characters:

Escape Meaning
\n Newline
\s Space
\t Tab
a\3 Repeat preceding character 3 times (yields aaa)
\Y, \m, \d Dynamic year, month, day placeholders

Critical: Always use a code-friendly editor (VS Code, Vim, Sublime Text) that preserves UTF-8 encoding and actual tab characters. Standard Windows Notepad may convert tabs to spaces or change encoding, causing RIME to fail parsing.

Adding Entries to custom_phrase.txt

Basic Text Entries

To add a simple phrase mapping:

  1. Open custom_phrase.txt from the repository root.
  2. Append a new line with the tab-separated values.
  3. Save and redeploy.
你好世界	nh	5
RIME输入法	rime	10

Typing nh will surface 你好世界 as a top candidate, while rime brings up RIME输入法 with higher priority due to the weight of 10.

Using Escape Sequences for Formatting

For multi-line text or special spacing, use escape sequences in the output column:

静夜思\n\s\s\s李白\n床前明月光\n疑似地上霜\n举头望明月\n低头思故乡	jys	5
  • \n inserts line breaks.
  • \s\s\s inserts three leading spaces.
  • When you type jys, RIME presents a formatted poem with proper line breaks and indentation.

Dynamic Date and Time Placeholders

The file supports runtime variables that expand when you type:

今天是\Y-\m-\d	today	5
当前时间\T\K	nowtime	5
  • \Y-\m-\d expands to the current date (e.g., 今天是2026-02-24).
  • \T and \K insert time components.
  • These placeholders evaluate at insertion time, not when the file is saved.

Merging External Phrase Collections

The repository includes supplementary phrase files like jm_flypy.txt and jm_zrm.txt. To merge them into your main dictionary without manual copy-pasting:

cat jm_flypy.txt >> custom_phrase.txt
cat jm_zrm.txt >> custom_phrase.txt

This appends all entries from external collections to your custom_phrase.txt. After merging, verify that tab separators were preserved and no blank lines were corrupted.

Redeploying the Schema

After modifying custom_phrase.txt, you must redeploy the RIME schema for changes to take effect:

  1. Save the file with UTF-8 encoding.
  2. Trigger deployment via your RIME frontend (e.g., click "Deploy" in the system tray menu, or use the keyboard shortcut).
  3. Alternatively, restart the input method completely.

Without redeployment, RIME continues using the cached version of the dictionary.

Summary

  • custom_phrase.txt is a tab-separated user dictionary loaded by table_translator@custom_phrase in wanxiang.schema.yaml.
  • Each line requires three columns: output phrase, input code, and optional weight (default 5).
  • Use escape sequences like \n for newlines, \s for spaces, and \Y\m\d for dynamic dates.
  • Never use plain Notepad; always edit with UTF-8 capable software to preserve tabs.
  • Redeploy the RIME schema after saving changes to activate new phrases immediately.

Frequently Asked Questions

What is the exact format for custom_phrase.txt entries?

Each entry must follow output<TAB>code<TAB>weight using actual tab characters, not spaces. The output is the inserted text, the code is what you type, and the weight is an integer priority (higher numbers rank first). Omitting the weight defaults to 5.

How do I add line breaks or spaces in custom phrases?

Use escape sequences in the output column: \n for newlines and \s for spaces. For example, Line1\nLine2 creates a two-line phrase. To insert multiple spaces, use \s repeatedly or combine with repeat syntax like \s\3 for three spaces.

Can I use dynamic variables like current date in custom phrases?

Yes. The custom_phrase.txt header documents placeholders like \Y (year), \m (month), \d (day), \T (time), and \K (clock). When you type the associated code, RIME expands these to the current system values at runtime.

Why aren't my new phrases showing up after editing?

This usually happens if you forgot to redeploy the schema after saving, or if your editor converted tabs to spaces. Verify the file uses UTF-8 encoding and contains actual tab characters between columns. Redeploy via the RIME menu or restart the input method to reload custom_phrase.txt.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →