linux vim输入法切换,完美解决Mac下Vim/Emacs的输入法切换问题

背景

vi-mode 是一种高效的编辑方式,但是最令人头疼的莫过于在普通模式下输入命令的时候却被输入法挡住,对于我这种经常忘记切输入法的人来说非常痛苦。

为了解决这种问题,很早以前就有了 vim-scripts/fcitx.vim (for Vim)和 cute-jumper/fcitx.el (for Emacs)。利用插件和 fcitx

进行沟通,让输入法随着用户的需要自动改变。

但是 fcitx 是 Linux only 的,OS X 下无法使用。

fcitx-remote

是 fcitx 提供的一个命令行小工具,用于在命令行下控制输入以及获取输入法状态。早期版本的 fcitx.vim

和 fcitx.el 通过这个程序来和 fcitx 进行交互。于是我受到启发,如果在 OS X 下实现一个 fcitx-remote,和 fcitx

保持一致的使用方法, fcitx.vim 和 fcitx.el 就可以在 OS X 直接使用了。所以有了这个项目:CodeFalling/fcitx-remote-for-osx

安装

homebrew

homebrew 的 core repo 要求 30 天以上的 Github 项目才能加入,现在可以通过 brew tap

安装。brew tap codefalling/fcitx-remote-for-osxbrew install codefalling/fcitx-remote-for-osx/fcitx-remote-for-osx --with-baidu-pinyin

--with-baidu-pinyin表示百度拼音。

你可以使用 brew info codefalling/fcitx-remote-for-osx/fcitx-remote-for-osx来查看支持其他输入法的选项。

==> Options

--with-baidu-pinyin

Build fcitx-remote for osx with baidu-pinyin support

--with-baidu-wubi

Build fcitx-remote for osx with baidu-wubi support

--with-osx-pinyin

Build fcitx-remote for osx with osx-pinyin support

--with-qq-wubi

Build fcitx-remote for osx with qq-wubi support

--with-sogou-pinyin

Build fcitx-remote for osx with sogou-pinyin support

--with-squirrel-rime

Build fcitx-remote for osx with squirrel-rime support

手工安装

git clone https://github.com/CodeFalling/fcitx-remote-for-osx cd fcitx-remote-for-osx xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS CHINNESE_KEYBOARD_LAYOUT=@\"com.baidu.inputmethod.BaiduIM.pinyin\"' install

编译完成后可执行文件会被安装到 /usr/local/bin/fcitx-remote

构建指令看起来比较长,是因为要定制所用的中文输入法,对应输入法的 imname

可以在 Github 看到,如果表里没有你用的输入法,你可以先安装了fcitx-remote,然后用 fcitx-remote -n来获取当前的输入法名,欢迎以任何形式向我补充。

我使用的是百度拼音,如果你使用其他输入法,编译参数要做响应的修改。

二进制文件

Emacs

由于我自己是 emacs 用户所以先提 emacs, fcitx-remote可以和 cute-jumper/fcitx.el 配合使用, 但是不要使用 =(fcitx-prefix-keys-turn-on)= 和 =(fcitx-prefix-keys-setup)= (即不要直接使用 =fcitx-default-setup= 什么的),会导致 emacs 假死,原因不详。我自己使用的配置是

之前使用的时候会卡死,后来发现是因为我用的 fish-shell,在 emacs 的配置里加上一句 (setq shell-file-name "bash") ,问题就完美解决了。

Vim

本来以为 vim 是使用不了这个小工具的,但是后来发现老版本的 fcitx.vim同样使用 fcitx-remote,然后简单的修改下(不然会很卡),放在了CodeFalling/fcitx-vim-osx 。可以直接通过 vundle安装,这个版本也可以直接在 Linux 下使用。反馈使用中碰到任何问题,欢迎去 CodeFalling/fcitx-remote-for-osx 开 issue 或者直接评论。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值