为 Vim/Neovim 提供基于 jieba 的 word motion / text object 增强。
For English, see below.
w / W / b / B / e / E / ge / gE / iw / iW / aw / aW),覆盖 normal / visual / operator-pending 模式,支持计数前缀与所有字符操作,支持 register,以及通过 tpope/vim-repeat 支持 . 重复上一操作。'iskeyword' 设置,允许自定义分词边界;支持惰性加载词典,按需启用。:h jieba 在 Vim/Nvim 内查看帮助。+python3 或 +python3/dyn 或 +python3/dyn-stable。vim-plug (Vim / Neovim):
Plug 'kkew3/jieba.vim', { 'branch': 'release', 'do': { -> jieba_vim#install() } }
lazy.nvim (Neovim):
{
"kkew3/jieba.vim",
branch = "release",
build = ":call jieba_vim#install()",
init = function()
vim.g.jieba_vim_lazy = 1
vim.g.jieba_vim_keymap = 1
end,
},
其中,jieba_vim#install() 优先下载预编译 cdylib,下载失败时回退至本地编译(需要 cargo)。
w 不跳过标点、W 跳过标点)的基础上,使以下命令识别中文词语:b、B、ge、gE、w、W、e、Eiw、iW、aw、aWnmap / xmap / omap(text object 没有 nmap);4w、c2e、3daw 等;d、c、y、g~ 等;tpope/vim-repeat 时可以使用 . 重复上一操作:dw. 相当于 dwdw。可提前高亮 nmap 下的光标跳转位置:
" 示例映射
nmap <LocalLeader>jw <Plug>(Jieba_preview_w)
nmap <LocalLeader>je <Plug>(Jieba_preview_e)
" 取消预览
nmap <LocalLeader>jc <Plug>(Jieba_preview_cancel)
另提供 :JiebaPreviewCancel 命令用于取消按词跳转位置预览。
当前暂不支持预览 text objects。
默认不映射任何按键,通过 <Plug>(Jieba_*) 映射与命令供用户自由配置。若希望快速启用默认行为(不包括跳转预览),可在 ~/.vimrc 中:
let g:jieba_vim_keymap = 1
| 选项 | 说明 | 默认值 |
|---|---|---|
g:jieba_vim_lazy |
是否延迟加载词典直到中文出现 | 1(是) |
g:jieba_vim_user_dict |
用户自定义词典路径 | "" |
g:jieba_vim_keymap |
是否自动启用默认键映射 | 0(否) |
若想在本地运行针对 rust 实现的测试,部分测试可通过如下命令运行:
cargo test --locked -r --manifest-path rust_backend/Cargo.toml
其余测试比较复杂,请参见 CI。
见 TODO.md。
见 docs/faq.md。
见 docs/demo.
Apache license v2;部分文件参照 vim-LICENSE.txt.
w / W / b / B / e / E / ge / gE / iw / iW / aw / aW), covering normal / visual / operator-pending modes, supporting count prefixes and all character operators, supporting registers, and supporting . to repeat the last operation via tpope/vim-repeat.'iskeyword' settings, allowing custom word boundary definitions; supports lazy-loading dictionaries, enabling on-demand activation.:h jieba within Vim/Nvim.+python3 or +python3/dyn or +python3/dyn-stable.vim-plug (Vim / Neovim):
Plug 'kkew3/jieba.vim', { 'branch': 'release', 'do': { -> jieba_vim#install() } }
lazy.nvim (Neovim):
{
"kkew3/jieba.vim",
branch = "release",
build = ":call jieba_vim#install()",
init = function()
vim.g.jieba_vim_lazy = 1
vim.g.jieba_vim_keymap = 1
end,
},
Here, jieba_vim#install() prioritizes downloading the precompiled cdylib, falling back to local compilation (requires cargo) if the download fails.
w does not skip punctuation, whereas W does), the following commands are enhanced to recognize Chinese words:b、B、ge、gE、w、W、e、Eiw、iW、aw、aWnmap / xmap / omap (text objects have no nmap);4w, c2e, 3daw, etc.;d, c, y, g~, etc.;. can be used to repeat the last operation: dw. is equivalent to dwdw.Cursor movements under nmap can be previewed in advance:
" Example mappings
nmap <LocalLeader>jw <Plug>(Jieba_preview_w)
nmap <LocalLeader>je <Plug>(Jieba_preview_e)
" Cancel preview
nmap <LocalLeader>jc <Plug>(Jieba_preview_cancel)
Additionally, the :JiebaPreviewCancel command is provided to cancel word motion previews.
Preview for text objects is currently not supported.
By default, no keys are mapped; users can freely configure via <Plug>(Jieba_*) mappings and commands. If you wish to quickly enable default behavior (excluding cursor movement preview), add the following to ~/.vimrc:
let g:jieba_vim_keymap = 1
| Option | Description | Default |
|---|---|---|
g:jieba_vim_lazy |
Whether to delay loading the dictionary until Chinese characters appear | 1 (yes) |
g:jieba_vim_user_dict |
Path to user-defined custom dictionary | "" |
g:jieba_vim_keymap |
Whether to automatically enable default key mappings | 0 (no) |
To run tests against the Rust implementation locally, a portion of tests can be executed with the following command:
cargo test --locked -r --manifest-path rust_backend/Cargo.toml
For the remaining, please refer to CI.
See TODO.md.
See docs/faq.md.
See docs/demo.
See docs/benchmark。
Apache License v2; with a handful of files following vim-LICENSE.txt.