Skip to content

rlue/vim-barbaric

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⌨️ Barbaric

vim + non-Latin input = pain. Barbaric is the cure.

Why?

Normal mode mappings (e.g., h / j / k / l) are all 8-bit ASCII characters. That means that when you want to work on a file in Russian (or Greek or Chinese), you’ve got to switch back to English (or Spanish or German) every time you leave Insert mode.

Barbaric detects which input method is active when you first launch vim, then again any time you leave Input mode, and switches between them for you automatically.

No, I mean why ‘Barbaric’?

From Wikipedia (emphasis mine):

The Greeks used the term barbarian for all non-Greek-speaking peoples, including the Egyptians, Persians, Medes and Phoenicians, emphasizing their otherness, because the language they spoke sounded to Greeks like gibberish represented by the sounds “bar bar bar”....

The Romans adapted the term to refer to anything non-Roman.

Vim doesn’t play nicely with non-Latin scripts; i.e., input languages of non-Roman origin. Ipso facto, this is a plugin for barbarians.

Supported IMEs

  • macOS (requires xkbswitch-macosx)

    # Install via:
    $ curl -o /usr/local/bin/xkbswitch https://raw.githubusercontent.com/myshov/xkbswitch-macosx/master/bin/xkbswitch
  • fcitx

  • ibus

  • xkb-switch

If you need support for another IME or input system, consider:

  • built-in support for X11 and MS-Windows IMEs (:help mbyte-XIM / :help mbyte-IME),
  • built-in multi-byte keymaps (:help mbyte-keymap / explained here), or
  • vim-xkbswitch.

Installation

There are lots of vim plugin managers out there. I like vim-plug.

Usage

Barbaric should work out of the box provided that whenever you launch vim, the active input method is the one you want to use in Normal mode. If that’s not the case, be sure to set the first option in the configuration section below.

Known bugs

On macOS, in certain input methods (notably Chinese and Korean), switching windows away from vim and back can cause xkbswitch to malfunction. The problem is described here.

Configuration

Barbaric does its best to work out of the box with zero configuration. To change its default behavior, modify the lines below and add them to your .vimrc.

" The IME to invoke for managing input languages (macos, fcitx, ibus, xkb-switch)
let g:barbaric_ime = 'fcitx'

" The input method for Normal mode (as defined by `xkbswitch -g`, `ibus engine`, or `xkb-switch -p`)
let g:barbaric_default = 0

" The scope where alternate input methods persist (buffer, window, tab, global)
let g:barbaric_scope = 'buffer'

" Forget alternate input method after n seconds in Normal mode (disabled by default)
" Useful if you only need IM persistence for short bursts of active work.
let g:barbaric_timeout = -1

" The fcitx-remote binary (to distinguish between fcitx and fcitx5)
let g:barbaric_fcitx_cmd = 'fcitx5-remote'

" The xkb-switch library path (for Linux xkb-switch users ONLY)
let g:barbaric_libxkbswitch = $HOME . '/.local/lib/libxkbswitch.so'

Troubleshooting

  • Some users have reported latency between leaving insert mode and the automatic switching of input methods (#9, #15, and this comment). If you experience this problem, try this:

    " .vimrc
    
    set ttimeoutlen=0

License

The MIT License (MIT)

Copyright © 2017 Ryan Lue

About

Automatic input method switching for vim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •