nvim im select

使用 vim 进行中文输入,遇到的最大困难是要频繁的切换中英文,这个操作是比较繁琐的,往往会打断创作思路。我们的想法是,在 insert 模式下,使用中文输入;但是在 normal 模式下,则自动切换到英文输入,如此可以方便各种键位的操作。

在网上找了一会,发现有一个 im-select 的插件可以实现这个目的,使用起来非常的丝滑。

im-select

1
2
3
4
5
6
7
8
9
## 需要确认以下输入法其中的任何一个有安装即可
apt-get install fcitx
sudo apt install fcitx5
sudo apt install ibus

## install sogou and then reboot
apt --fix-broken install

## https://www.thisfaner.com/p/ubuntu-ime-install/
 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
return {
    "keaising/im-select.nvim",
    config = function()
        require("im_select").setup({
            -- IM will be set to `default_im_select` in `normal` mode
            -- For Windows/WSL, default: "1033", aka: English US Keyboard
            -- For macOS, default: "com.apple.keylayout.ABC", aka: US
            -- For Linux, default:
            --               "keyboard-us" for Fcitx5
            --               "1" for Fcitx
            --               "xkb:us::eng" for ibus
            -- You can use `im-select` or `fcitx5-remote -n` to get the IM's name
            -- default_im_select  = "com.apple.keylayout.ABC",
            default_im_select  = "1",

            -- Can be binary's name, binary's full path, or a table, e.g. 'im-select',
            -- '/usr/local/bin/im-select' for binary without extra arguments,
            -- or { "AIMSwitcher.exe", "--imm" } for binary need extra arguments to work.
            -- For Windows/WSL, default: "im-select.exe"
            -- For macOS, default: "macism"
            -- For Linux, default: "fcitx5-remote" or "fcitx-remote" or "ibus"
            default_command = "fcitx-remote",

            -- Restore the default input method state when the following events are triggered
            set_default_events = { "VimEnter", "FocusGained", "InsertLeave", "CmdlineLeave" },

            -- Restore the previous used input method state when the following events
            -- are triggered, if you don't want to restore previous used im in Insert mode,
            -- e.g. deprecated `disable_auto_restore = 1`, just let it empty
            -- as `set_previous_events = {}`
            keep_quiet_on_no_binary = false,

            -- Async run `default_command` to switch IM or not
            async_switch_im = true
        })
    end,
}

标点符号的问题

  1. 配置文件在目录~/.config/fcitx/data
  2. 配置文件是 punc-ng.mb-zh_CNpunc.mb.zh_CN
  3. 填写,然后重启输入法即可
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
. 。
, ,
? ?
" “ ”
: :
; ;
' ‘ ’
< 《
> 》
\ 、
! !
$ ¥
^ ……
* *
_ ——
( (
) )
[ 「
]  」
~ ~

ref

  • [我的 fcitx 配置]:https://github.com/alswl/fcitx-config
william 支付宝支付宝
william 微信微信
0%