I'm running into a bothersome issue I can't seem to solve myself. When I open gvim I receive the error E285: Failed to create input context

The error always comes twice, and looks to be related to XIM input. Although this is the first I've ever heard of IM and XIM as I am only ever working in English.
I don't normally use gvim but I recently started using qutebrowser and when I try to use gvim for input fields the errors pop up in a gui, and require more action from me until I can actually type into the buffer.

Basic Specs:

uname -a
Linux pop-os 5.4.0-7634-generic #38~1592497129~20.04~9a1ea2e-Ubuntu SMP Fri Jun 19 22:43:37 UTC  x86_64 x86_64 x86_64 GNU/Linux
VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31) Huge version
with X11-Athena GUI. +X11, +xim, +xfontset.

What I've tried:

  1. Running gvim with --clean or like gvim -u NONE -U NONE -N -i NONE file.txt. I was hoping to narrow down if a certain config somewhere was causing the issue, but the errors prevailed even when specifying this clean startup.
  2. Variations of the flags above, i.e. using my vimrc, taking some flags out etc.
  3. Running sudo gvim file.txt. This is the only way I've been able to open gvim without the errors. Unfortunately not a valid solution as I would like to run with my configs and running with -u\-U $HOME/.vimrc gives way more errors from plugins and personal scripts as my home directory is now /root/. last problem is I'm not wanting to type my password every time.
  4. Trying to set the guifont when has("gui_running") and has("x11") are true. Plus some other variants but this is the most direct logic path I could get to 'work'. However, this was a bug of it's own for me because even though I could set the guifont, and gvim could echo it back to me, the font, it's size, and other aspects would not actually change. It also never subdued the error messages in question. example of setting guifont: set guifont=-*-courier-medium-r-*-*-11-*-*-*-*-*-*-*. I tried multiple styles of setting it but to no avail, so bonus points if someone konws how to fix this because I would like to change those settings.
  5. Using the -f file.txt as suggested for some other bugs, but has no effect on the error messages.

Final Thoughts: I'm at a loss for new solutions as searches for the error only results in a few similar issues from 2014 or older, that haven't fixed my problem. And since even the --clean startups were unsuccessful I can't even drill down a certain config causing it, but using sudo actually works, but I am unable to say why.

The one solution I haven't tried is the last post on the following link, to get the source code and disable xim, but the instructions were just vague enough I wasn't sure how to do it myself. https://www.linuxquestions.org/questions/linux-software-2/gvim-complains-that-it-failed-to-create-input-context-926593/

  • Welcome to Vi and Vim!
    – D. Ben Knoble
    Jul 21, 2020 at 12:14
  • Hello, could you solve this problem? I have the same situation after upgrading to ubuntu 20 tls, thanks ...
    – iqmaker
    Feb 16, 2021 at 19:18

2 Answers 2


I had the same problem when starting gvim from a shell script. Looking at the code vim ignores the fact that creating this context failed. It is just annoying the users with this message except when the "not a term" flag is set. To set that flag specify --not-a-term on the command line and the error message vanishes.

gvim --not-a-term filename
  • Somehow missed that flag back in the day when trying to solve this myself. This was an instant fix and the use case I had for it I basically abandoned, and can now start using that workflow again. My use case is using it to enter text into fields while using Qutebrowser. Thanks for taking a second to post your answer! Jul 28, 2022 at 16:21

Same problem, after upgrade Ubuntu (20.04 TLS) worked for me:

sudo apt-get remove vim-athena vim-gui-common vim-gtk3
sudo apt-get install vim-gtk3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.