6 ms·
Show HN: Using Vim as an input method editor (IME) for X11 apps
As a Vim user, I often use Vim to write some text and then copy & paste it into another text field of GUI apps (e.g. browsers, chat apps, etc.),
because almost all of these text fields provide only very basic editing functions.
A while ago, I came up with an idea: what if we could use Vim as an IME?
Ordinary IMEs are used to input some non-English characters, but the essential functions of IME are
1) receiving a keyboard sequence
2) process the key sequence and outputting a text
These functions are the same as text editor's.
So I thought implementing an IME that can be used with Vim keybindings could be a good solution for the above problem.
After that I learned mechanisms of IME for Linux desktop and tried to develop an experimental IME.
- jacob019 4y agoLove it, and the video. Will install tomorrow.
- Tcepsa 4y agoThank you for sharing this, and for providing a way to use other editors--I can't wait to try it with an Emacs client! (I had something similar in the past with just Firefox; I love the idea of being able to access it from anywhere!)
- colordrops 4y agoThis is brilliant. Now if I could only get IMEs to work for more than a few weeks before they break...
- leephillips 4y agoOh hell yes.
- vthriller 4y agoSee also: vi keybindings for GTK2/3: https://github.com/polachok/gtk-vikb https://github.com/polachok/gtk-vikb (not an active project though)
- gandalfff 4y agoAny experience with this? I would suspect that it would work with GTK2, but not for current GTK3/4.
- vthriller 4y agoI was actually the one who submitted patches for GTK3 support! But, yes, it's never going to work with GTK4, at least not without complete overhaul. I don't daily-drive it though, mostly because I never found time to update rather limited set of keybindings, a task that seems way more involving than a couple of little fixes that were needed to support GTK3.
- noiwillnot 4y agoVery interesting, I am sure that if something like this is packaged in Linux distros would become popular.
- mihaigalos 4y agoThis is blackmagic. Nice work! Q: Why not publish it to crates.io (cargo publish)?
- yewenjie 4y agoHow difficult would it be to port it to Wayland?
- algon 4y agoI'm not familiar with how IMEs work in Wayland at the moment, but I guess it is possible by the similar way as XIM. I would like to investigate the protocol later.
- pinsl 4y agoTridactyl can also do this for text input fields in firefox (:editor).
- dijit 4y agoqutebrowser too; I have it bound to ^E
- fyresala 4y agoI have been expecting this for long
- 3np 4y agoReally cool; thank you for sharing! Curious: Did you consider neovim over vim and if so what made you stick with vim? AAUI neovim has these kinds of "embedded" use-cases in mind and intends to be smoother than vanilla vim.
- algon 4y agoThank you for the information. Actually I didn't so stick to vanilla Vim and have no intention to avoid Neovim at all! FYI, since this IME embeds a terminal emulator it should be able to use with other terminal-based editors (including Neovim) by applying almost no changes to the editor's codebase.
- psacawa 4y agoPlease check out firenvim, which accomplishes this very useful trick in a site-configurable manner and is compatible with Tridactyl. https://github.com/glacambre/firenvim https://github.com/glacambre/firenvim
- rnmp 4y agoLooks so good. Is it compatible with Neovim? Thanks for sharing!
- velox_neb 4y agoDepressing to think that, even if you find a way to make this work, it'll be deprecated in a few years as most distros move to Wayland. Then if you figure it out in Wayland, it'll probably break again when they come up with some new backwards incompatible bullshit. Everything in desktop Linux is like this.
- OJFord 4y agoYou say that like desktop Linux is new, or we only just switched to X11.
- gigatexal 4y agoWill this let me use vim bindings in Google docs?
- finnh 4y agoOn OSX w/ Chrome I use wasavi[0], an extension that implements a nice subset of vim directly in the text area (much like OP's system, but not using actual vim). Works really well, better than other extensions I've tried that attempt to ~shellout to $EDITOR and then sync back to the input area. [0] https://github.com/akahuku/wasavi https://github.com/akahuku/wasavi
- zvr 4y agoWow, that brings back memories... Back in the '90s I had made an X Input Method that used vim -- essentially forked a gvim process on a temporary file and read the file upon termination. It was a nice learning experience, but not very useful. Besides textareas in browsers (the main use, where a number of other solutions currently exist), a fun demo was to use vi for changing formulas in a spreadsheet (I assume it must have been StarOffice back then).