警告: 所有配置,不要有重复的patch,如果有就合并patch。千万注意缩进。

有时候会有打不出汉字的bug,未必是配置出错,重新部署无法解决,可以尝试重启解决。

rime 默认没有双拼的解决办法

选择方案界面 - 获取更多输入方案 在弹出的 cmd 窗口中输入:

double-pinyin

既可安装双拼。

设置自定义短语

  1. 新建或者修改用户文件夹中的double_pinyin_flypy.custom.yaml
    复制如下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    patch:
    engine/translators:
    - punct_translator
    - reverse_lookup_translator
    - script_translator
    - table_translator@custom_phrase
    - table_translator
    custom_phrase:
    dictionary: ""
    user_dict: custom_phrase
    db_class: stabledb
    enable_completion: false
    enable_sentence: false
    initial_quality: 1
  2. 新建文件: Custom_phrase.txt
    短语``编码``词频的格式来录入自定义短语,用tab分隔,每个词一行。

    1
    2
    为什么	wsm	1
    不知道 bzd 1
  3. 重新部署。

注意: 分隔符一定是且只是 1 个tab,不能用空格代替。

Rime 导入第三方词库

可导入搜狗、QQ、百度等任意输入法词库。

  1. 下载深蓝词库转换

  2. 自己找词库下载,比如:

    https://pinyin.sogou.com/dict/detail/index/4

    https://pinyin.sogou.com/dict/detail/index/11640

  3. 深蓝词库转换 把词库文件转换成Rime 格式,并保存文件。

    可将两个词库文件同时拖放转换成一个文件。

  4. 修改 double_pinyin_flypy.custom.yaml 文件,新增 patch:

    1
    2
    patch:
    "translator/dictionary": custom

    该行缩进两个空格,且文件中只能有一个patch,如果已经有patch,则需要合并。

    比如之前已经添加了自定义短语配置,则此处应为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    patch:
    engine/translators:
    - punct_translator
    - reverse_lookup_translator
    - script_translator
    - table_translator@custom_phrase
    - table_translator
    custom_phrase:
    dictionary: ""
    user_dict: custom_phrase
    db_class: stabledb
    enable_completion: false
    enable_sentence: false
    initial_quality: 1
    "translator/dictionary": custom
  5. 新建 yaml 文件: custom.dict.yaml

    复制粘贴以下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ---
    name: custom
    version: "2019.11.20"
    sort: by_weight
    use_preset_vocabulary: true
    #拼音输入法词库补充文件-小众但好用-八零笔记
    import_tables:
    - luna_pinyin
    ...
  6. 把刚才词库转换后的内容全选复制(几十万行),粘贴到 custom.dict.yaml 文件 ... 的后面并保存。

  7. 重新部署

固顶字

同时满足单键打字始终固顶,其它词只在固顶字后面做词频调整这两个条件。

  1. 新建词库 custom_top.dict.yaml

  2. 复制粘贴如下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    ---
    name: custom_top
    version: "2019.11.20"
    sort: original
    use_preset_vocabulary: true
    #固定词序单字
    ...

    去 q 1
    我 w 1
    他 t 1
    有 y 1
    哦 o 1
    的 d 1
    个 g 1
    和 h 1
    就 j 1
    快 k 1
    了 l 1
    在 z 1
    下 x 1
    才 c 1
    不 b 1
    你 n 1
    没 m 1

    内容可根据需要修改。

  3. 修改词库文件: custom.dict.yaml

    把文件前面的声明内容 - luna_pinyin 后面加一行 - custom_top 并保存。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    ---
    name: custom
    version: "2019.11.20"
    sort: by_weight
    use_preset_vocabulary: true
    #拼音输入法词库补充文件-小众但好用-八零笔记
    import_tables:
    - luna_pinyin
    - custom_top
    ...
  4. 重新部署。

新增其它词库

rime 允许多个词库并存,只需要用深蓝词库转换 转换一下词库,然后复制到配置好的词库文件中既可。

需要注意几点,

  1. 词库文件的命名和该文件内容中声明的文件名必须一致,比如词库文件声明内容中的 name: google,则该文件名必须为 google.dict.yaml

  2. 声明内容中的 sort: by_weight 是词序可调频,sort: original 是固定词序,正常都设置sort: by_weight

  3. 词库文件制作完成后,需要在 custom.dict.yaml 中配置加载,也就是 import_tables: 项下的

    1
    2
    - luna_pinyin
    - custom_top

    等内容,如果 name: google,则文件名应该是 google.dict.yaml,所以 custom.dict.yaml 下的声明文件内容应该为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ---
    name: custom
    version: "2019.11.20"
    sort: by_weight
    use_preset_vocabulary: true
    #拼音输入法词库补充文件-小众但好用-八零笔记
    import_tables:
    - luna_pinyin
    - custom_top
    - google
    ...

去除候选生僻字

修改 double_pinyin_flypy.schema.yaml 文件

1,在 switches: 下加入子项:

1
2
3
4
5
- options: [ utf8, gb2312]
reset: 1
states:
- UTF-8
- GB2312

修改后的内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
switches:
- name: ascii_mode
reset: 0
states: [ 中文, 西文 ]
- name: full_shape
states: [ 半角, 全角 ]
- name: simplification
states: [ 漢字, 汉字 ]
- name: ascii_punct
states: [ 。,, ., ]
- options: [ utf8, gb2312]
reset: 1
states:
- UTF-8
- GB2312

2,在 engine 的子项 filters 下加入子项 - charset_filter@gb2312

修改后的内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
engine:
processors:
- ascii_composer
- recognizer
- key_binder
- speller
- punctuator
- selector
- navigator
- express_editor
segmentors:
- ascii_segmentor
- matcher
- abc_segmentor
- punct_segmentor
- fallback_segmentor
translators:
- punct_translator
- reverse_lookup_translator
- script_translator
filters:
- simplifier
- uniquifier
- charset_filter@gb2312

3,在 translator 下加入子项 enable_charset_filter: false

修改后的内容如下:

1
2
3
4
5
translator:
dictionary: luna_pinyin
prism: double_pinyin_flypy
enable_charset_filter: false
##后面省略...

保存文件后重新部署,默认使用 gb2312 字符集,如果需要切换到 UTF-8 字符集,用 ctrl+~ ,调出方案选项,选择 UTF-8 既可。

修改候选词个数

打开 default.custom.yaml ,找到 patch: ,如果没有则新增 patch:

patch: 最后新增子项

1
"menu/page_size": 9

这里的9就是候选字的个数,根据需要自己修改。

注意缩进

我的文件修改前是这样的:

1
2
3
patch:
schema_list:
- {schema: double_pinyin_flypy}

添加配置后是这样的:

1
2
3
4
patch:
schema_list:
- {schema: double_pinyin_flypy}
"menu/page_size": 9

关闭左右 shift 切换英文

rime 默认单击左右 shift 键切换中英文输入法,我个人比较习惯 ctrl+空格 的方式切换,所以选择关闭左右 shift 键切换英文。

还是 default.custom.yaml ,找到 patch: ,在后面新增子项: "ascii_composer/switch_key": ,然后再该项目下再增加子项 Shift_L: noopShift_R: noopLR 分别对应 左shift右shift 。也可以根据需要只关闭一个。

修改后的配置:

1
2
3
4
5
6
7
patch:
schema_list:
- {schema: double_pinyin_flypy}
"menu/page_size": 9 # 候选词个数
"ascii_composer/switch_key":
Shift_L: noop # 关闭左shift切换英文
Shift_R: noop # 关闭右shift切换英文

Caps 键直接切换大小写

不知道别人怎么想,我个人觉得 Caps 键不能直接切换到大写英文状态真的很傻,幸好我们可以修改配置。

还是打开 default.custom.yaml ,找到 patch: 下面的子项 "ascii_composer/switch_key":

在该项下面新增子项 Caps_Lock: commit_code 既可。

修改后的配置:

1
2
3
4
5
6
7
8
patch:
schema_list:
- {schema: double_pinyin_flypy}
"menu/page_size": 9 # 候选词个数
"ascii_composer/switch_key":
Shift_L: noop # 关闭左shift切换英文
Shift_R: noop # 关闭右shift切换英文
Caps_Lock: commit_code

双拼不自动显示全拼字母

Rime 双拼打字默认会显示全拼韵母,比如打 八零笔记 ,双拼按键 balkbiji ,但是屏幕上显示的是 balingbiji ,如果需要只显示双拼实际按键的 balkbiji,就可以用这个办法。

打开 double_pinyin_flypy.custom.yaml 文件,找到 patch:

新增子项: translator/preedit_format: {} 既可。

上面我们修改过这个配置文件,所以这里配置文件接上面的修改结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
patch:
engine/translators:
- punct_translator
- reverse_lookup_translator
- script_translator
- table_translator@custom_phrase
- table_translator
custom_phrase:
dictionary: ""
user_dict: custom_phrase
db_class: stabledb
enable_completion: false
enable_sentence: false
initial_quality: 1
"translator/dictionary": custom # 自定义词库
translator/preedit_format: {}

####在全角状态下部分按键直接输入半角符号

工作需要经常打全角的逗号和句号,其他符号用英文半角符号,同时还想把单引号改成

打开 double_pinyin_flypy.custom.yaml 文件,找到 patch:

新增子项和内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
punctuator:
import_preset: symbols
half_shape:
"!": "!"
"@": "@"
"#": "#"
"~": "~"
"$": "$"
"%": "%"
"^": "^"
"&": "&"
"*": "*"
"(": "("
")": ")"
"_": "_"
"=": "="
"[": "["
"]": "]"
"{": "{"
"}": "}"
'\': "、"
'|': '|'
';': ';'
':': ':'
"'": {pair: ["「", "」"]}
'"': '"'
"<": "<"
">": ">"
'/': '/'
'?': '?'

其中 half_shape: 下的符号,左边为对应按键,右边为上屏字符。

修改后的配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
patch:
engine/translators:
- punct_translator
- reverse_lookup_translator
- script_translator
- table_translator@custom_phrase
- table_translator
custom_phrase:
dictionary: ""
user_dict: custom_phrase
db_class: stabledb
enable_completion: false
enable_sentence: false
initial_quality: 1
"translator/dictionary": custom
translator/preedit_format: {}
punctuator:
import_preset: symbols
half_shape:
"!": "!"
"@": "@"
"#": "#"
"~": "~"
"$": "$"
"%": "%"
"^": "^"
"&": "&"
"*": "*"
"(": "("
")": ")"
"_": "_"
"=": "="
"[": "["
"]": "]"
"{": "{"
"}": "}"
'\': "、"
'|': '|'
';': ';'
':': ':'
"'": {pair: ["「", "」"]}
'"': '"'
"<": "<"
">": ">"
'/': '/'
'?': '?'

词库文件同步

rime 支持多系统,但是没有云词库同步,不过多设备之间能通过自定义同步文件来同步词库。

打开 installation.yaml ,在最后新增一行 sync_dir: 'D:\RimeSync',其中 D:\RimeSync 是自定义词库同步目录,根据自己需要修改。

我的修改后的文件内容:

1
2
3
4
5
6
7
8
distribution_code_name: Weasel
distribution_name: "小狼毫"
distribution_version: 0.14.3
install_time: "Mon Apr 1 13:24:38 2019"
installation_id: "1d11aeee-e567-4fe9-bbc8-232e7ad994fc"
rime_version: 1.5.3
update_time: "Thu Aug 8 21:01:53 2019"
sync_dir: 'D:\RimeSync'

设置好后,在任务栏右键点击小狼毫输入法,选择 用户资料同步 ,既可在指定目录找到同步文件夹,把文件夹复制到另一个设备上,用同样的方法修改配置文件,然后再同步既可实现多设备同步词库。

也可以把几个设备的输入法同步目录设置成同步盘目录,这样几个设备都可以用同步盘中的词库,免去复制词库文件的麻烦。

打开指定程序自动切换英文输入

某些游戏或工具,打开后只需要英文输入,我们可以设置这个程序打开后只能使用英文输入,免去切换的麻烦。

下面以我常用的 shell 工具 xshell 为例:

首先需要查到该程序的进程名,win10 下我们用 ctrl+alt+del 调出任务管理器,在 详细信息 页面中找到 xshell 的进程,查看进程名称为 xshellcore.exe

找到进程名称后,打开 weasel.custom.yaml ,在 patch 下新增子项

1
2
"app_options/xshellcore.exe":
ascii_mode: true

修改后的文件内容:

1
2
3
patch:
"app_options/xshellcore.exe":
ascii_mode: true

注意这里的 xshellcore.exe 就是之前获取的进程名称。

我还有另一个进程名称为 mintty.exe 的程序也需要该设置。

于是修改后的文件内容:

1
2
3
4
5
patch:
"app_options/mintty.exe":
ascii_mode: true
"app_options/xshellcore.exe":
ascii_mode: true

需要新增程序就以此类推。

记得重新部署。