惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
Latest news
Latest news
Help Net Security
Help Net Security
S
Security Affairs
Webroot Blog
Webroot Blog
The Hacker News
The Hacker News
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tor Project blog
Forbes - Security
Forbes - Security
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Help Net Security
L
Lohrmann on Cybersecurity
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
Cyberwarzone
Cyberwarzone
The Last Watchdog
The Last Watchdog
S
Securelist
N
News and Events Feed by Topic
S
Secure Thoughts
F
Fortinet All Blogs
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
量子位
M
MIT News - Artificial intelligence
F
Full Disclosure
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
P
Privacy International News Feed
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CERT Recently Published Vulnerability Notes

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN Mintty Tips and Configurations Generating Table of Contents for Markdown with Tagbar Convert Python Script to Exe on Windows with Pyinstaller Ubuntu on Windows Missing after Windows Update 使用代理加速 Mac 终端下载速度 My Experience with Several Zsh Plugin Managers 深圳租房小记 How to Install zplug inside Docker Container Why don't settings inside bashrc or bash_profile take effect? Setting Up Locale in Linux 谷歌 Adsense 申请及在 Hugo 中的配置 How to Write Algorithm Pseudo Code in LaTeX Nifty Nvim Techniques That Make My Life Easier -- Series 4 A Few Grammar Questions in Writing How to Read and Write Images with Unicode Paths in OpenCV Creating A Professional Table in LaTeX with booktabs How to Create Proper Folding for Vim/Nvim Configuration Linux Tips and Tricks -- s1 JPEG Image Orientation and Exif How Do I Show the Current File Path In Neovim? JPEG Image Quality in PIL Difference between view, reshape, transpose and permute in PyTorch Convert PIL or OpenCV Image to Bytes without Saving to Disk Fast Movement and Navigation Inside Vim or Neovim Unintuitive Behaviour of Case Sensitivity in Python glob Binding Keys in Zsh 几把机械键盘试用体验 Nvim Autocompletion with Deoplete Converting Markdown to Beautiful PDF with Pandoc Exclusive and Inclusive Motion in Neovim/Vim Nifty Nvim Techniques Which Make My Life Easier -- Series 3 Why Doesn't Jedi Autocompletion Work for Some Methods Vim-like Editing inside Browser Markdown 生成 HTML 时汉字之间出现多余空格问题 小米 9 安装谷歌商店(Google Play Store)与相关配置 Create Mappings That Take A Count in Neovim Spell Checking in Nvim English Words Completion inside Neovim/Vim How to Use Python Inside Vim Script with Neovim Nifty Little Nvim Techniques to Make My Life Easier -- Series 2 Setting up Ultisnips for Neovim Mac 上罗技 M590 鼠标设置 Nifty Little Nvim Techniques to Make My Life Easier -- Series 1 A Complete Guide on Writing LaTeX with Vimtex in Neovim Manipulating Images with Alpha Channels in Pillow Sublime Text Regular Expression Cheat Sheet Cropping Rotated Rectangles from Image with OpenCV Boosting Your Productivity on Terminal with Zsh and Plugins 最新版 Rime 输入法使用 (2022 更新) Display Image with Pillow inside Ubuntu on Windows Faster Directory Navigation with z.lua Cmder Advanced Configurations Nvim-qt Settings on Windows 10 Tmux Plugin Install and Management How to Debug Python Code in Terminal Markdown Writing and Previewing in Neovim -- A Complete Guide Line Number Settings for More Efficient Movement in Neovim 两个大规模中文语料库介绍以及处理 Windows 系统下几款程序员不可不用的神器 我的 2018 阅读清单 A Complete Guide to Neovim Configuration for Python Development How Is Newline Handled in Python and Various Editors? Two Issues Related to ImageFont Module in PIL 在 Listary 中调用 GoldenDict 或欧路词典查单词 Reading and Writing Text Files on Windows The Mathematics behind Font Shapes --- Bézier Curves and More 快速识别图片字体:字体识别工具介绍 Deoplete Failed to Load at Startup after Updating Python neovim Package What Is The Difference between pip, pip3 and pip3.6 Shipped with Anaconda3? Windows 10 系统下 Neovim 安装与配置
如何让 Neovim 中文输入时自动切换输入法
2021-02-25 · via jdhao's digital space
更新日志
  • 2023-06-18:增加 macism 以及 im-select.nvim 使用。
  • 2022-11-07:针对 macbook M1 CPU 设置添加说明,添加 smartim 插件使用。

Vim/Neovim 下输入中文最大的痛,就是在 Normal 模式下,需要频繁从中文模式切换到英文模式,来输入 Vim 的各种命令。本文总结几款插件,可以帮助我们在 macOS、Windows 下,进入 Normal 模式的时候自动切换到英文输入。

macOS#

vim-barbaric#

vim-barbaric 是一款帮助用户自动设置输入法模式的插件。

安装依赖#

在 macOS 下,需要额外安装 xkbswitch-macosx

curl -o /usr/local/bin/xkbswitch https://raw.githubusercontent.com/myshov/xkbswitch-macosx/master/bin/xkbswitch

在 macOS M1 芯片下,以上预编译的 binary 文件无法适用(仅针对 intel cpu),可以使用 这里 提供的 fork,自行编译,然后放到 /usr/local/bin 目录。

插件安装使用#

然后使用插件管理器安装该插件即可:

该插件开箱即用,无需额外设置。

vim-xkbswitch#

另外一款插件是 vim-xkbswitch

安装依赖#

这个插件也需要安装 xkbswitch-macosx,参考上面的安装步骤。另外该插件依赖 libxkbswitch-macosx,需要安装该库:

curl -o /usr/local/lib/libxkbswitch.dylib https://github.com/myshov/libxkbswitch-macosx/raw/master/bin/libxkbswitch.dylib

如果使用的 M1 芯片的 mac,则需要自己编译,参考 这个 issue,使用如下命令编译:

gcc -dynamiclib libxkbswitch.c -o bin/libxkbswitch.dylib

把生成的动态库放到 /usr/local/lib 下面:

cp bin/libxkbswitch.dylib /usr/local/lib

插件安装使用#

首先安装该插件:

Plug 'lyokha/vim-xkbswitch'

最后,在 Neovim 配置中加入下面的设置即可:

let g:XkbSwitchEnabled = 1

vim-macos-ime#

依赖安装#

首先安装这款插件的依赖 macism:

brew tap laishulu/macism
brew install macism

直接在命令行输入 macism 命令,可以插件当前正在使用的输入法的名称,这会在插件的设置中用到。

插件安装使用#

使用 Packer.nvim 的安装 vim-macos-ime 方法如下:

use { "laishulu/vim-macos-ime", config = function()
    vim.g.macosime_normal_ime = 'com.apple.keylayout.ABC'
    vim.g.macosime_cjk_ime = 'com.apple.inputmethod.SCIM.ITABC'
end}

变量 macosime_normal_ime 用来设置 normal 模式下的英文输入法,变量 macosime_cjk_ime 用来设置中文输入法,这两个变量一定要根据实际情况设置正确,否则插件无法工作。

有了以上的设置,安装插件以后,进入 insert 模式,插件会根据前一个字符是否是中文判断切换到中文还是英文输入法,虽然还不算非常智能(无法记录推出 insert 之前用的什么输入法),总体还可用。

im-select.nvim#

依赖安装#

curl -LO https://github.com/daipeihust/im-select/raw/8080ad18f20218d1b6b5ef81d26cc5452d56b165/im-select-mac/out/apple/im-select
chmod u+x im-select
mv im-select /usr/local/bin

第一次使用需要在系统设置 “Privacy & Security” 给这个可执行程序权限,否则无法运行。

插件安装使用#

使用 Packer 安装 im-select.nvim 方法如下:

use { 'keaising/im-select.nvim', config = function()
    require('im_select').setup {
        default_im_select  = "com.apple.keylayout.ABC"
    }
end}

default_im_select 参数设定 normal 模式下输入法,需要根据自己的情况设置。这款插件工作良好,可以记录上次离开 insert 之前使用的输入法,比 vim-macos-ime 智能一点。

smartim#

使用 packer.nvim 安装 smartim 如下:

use { "ybian/smartim", event = { "InsertEnter" }, config = function ()
        -- default IME mode
        vim.g.smartim_default = "com.apple.keylayout.ABC"
    end}

Note that we should set variable smartim_default based on our case. We can run the im-select executable without argument to get current mode:

这款插件和 im-select.nvim 其实差不多,也是以来 im-select ,只不过这个插件把 im-select 可执行文件集成到插件本身,不需要用户单独安装了。。。并且插件只支持了 macOS。

Windows#

以上的 im-select.nvim, vim-xkbswitch 也可以在 Windows 工作,有需要可以参考具体文档来配置。

neuims#

Windows 下可以安装 neuims:

if g:is_mac
  Plug 'lyokha/vim-xkbswitch'
elseif g:is_win
  Plug 'Neur1n/neuims'
endif

然后使用命令 IMSToggle 打开这个插件的功能。打开功能以后,使用 ESC 离开插入模式,输入法会自动切换到 US keyboard 模式,重新按 i 进入插入模式,会切换到之前的输入法 (注意是切换到了输入法的默认状态,如果输入法默认状态是英文输入,在中文输入状态,按 ESC 离开插入模式,再进入插入模式,输入法处于英文输入状态,目前似乎还不支持切换到输入法上次使用的状态,不过这已经比较好了)。