SmartIM is a plugin to make vim stand well with input methods. It switches the input method to the default keyboard (usually English) when leaving insert mode and switches back when you enter i 7A3B nsert mode again. It consists of 2 tiny programs:
im-select
: a command-line utility to get/set active input methodsmartim.vim
: a vim plugin to do automatic input method switch, usingim-select
It is Mac-only for now.
- Add this line to your ~/.vimrc file:
Plugin 'ybian/smartim'
- Open vim and run
:PluginInstall
cd ~/.vim/bundle
git clone git@github.com:ybian/smartim.git
- Clone this repository to your local disk
- Copy
im-select
andsmartim.vim
(both are underplugin
directory) to your vim plugin directory (usually.vim/plugins
)
Then, enjoy the convenience!
Because the command-line utility im-select
uses Mac specific APIs. It should be easy to develop
equivalents for other platforms but I just don't have the time to do so.
Sure. The usage is very simple: invoke it with no argument to get the ID string of current active input method; invoke it with an ID string to set current input method.
$ im-select
com.apple.keylayout.US # print the ID string of your active input method
$ im-select com.apple.keylayout.US # change your active input method
SmartIM assumes your default keyboard is US English (com.apple.keylayout.US). If you want to change this,
please add the following line to your .vimrc
:
let g:smartim_default = '<your_default_keyboard_id>'
Replace <your_default_keyboard_id>
with the ID string of your input method (which can be get via im-select
)