can I disable input method in vim normal mode

354 views
Skip to first unread message

jason.桂林

unread,
Nov 21, 2011, 12:37:01 PM11/21/11
to vim...@googlegroups.com
I normally input code in vim, it's all ascii chars, but sometime I need type chinese, for document and comment.

The input method is chinese at insert mode, and I press <esc>, and then I type some vim command, but this command can't be execute unless I switch input method back to english.

I will never use chinese input method at normal mode, and visual mode. so can I disable input method at these mode?

If I can't, I think it's a big problem.

--
Best regards,

Jason Green
桂林


Albin Olsson

unread,
Nov 21, 2011, 4:35:46 PM11/21/11
to vim...@googlegroups.com

The easiest way is to use US English, and use the 'keymap' setting in
Vim. When you use keymap, Vim will type the Chinese characters in
insert mode but the switch back to English in the other modes.

--
Albin Olsson, IT Consultant and Classic Connoisseur
www.albinolsson.se | albin....@gmail.com
+46 707 831 830

Tony Mechelynck

unread,
Nov 21, 2011, 9:32:08 PM11/21/11
to vim...@googlegroups.com, "jason.桂林"

It should be possible, but you have to make sure that Vim and the
input-method interface agree on which signals they exchange how and
when; and first and foremost, you must know that there are two different
input-method subpackages in Vim, one for Window (called IME or Global
IME) and one for Unix-like systems with X11 (called XIM).

See:
- for Windows (compiled with +multi_byte_ime or +multi_byte_ime/dyn)
:help mbyte-IME
- for X11 (compiled with +xim)
:help mbyte-XIM
- for all versions (compiled with either of the above)
:help 'imactivatekey'
:help 'imcmdline'
:help 'imdisable'
:help 'iminsert'
:help 'imsearch'

On Windows, if ":version" says your gvim is compiled with
+multi_byte_ime/dyn, type

:echo has('multi_byte_ime')

to see if the dynamic library has been found (it should normally have).
(The possible answers are 1=yes, 0=no.) On X11, +xim in the :version
text is usually assurance enough.

I recommend that you read the full section relevant for your OS, and
then the full text of the help for these five options. If after that
(and some experimenting) you need more help, come back here, but don't
forget to tell us (1) which OS you are on, and (2) (in full detail) what
you tried and what happened.


Best regards,
Tony.
--
Between 1950 and 1952, a bored weatherman, stationed north of Hudson
Bay, left a monument that neither government nor time can eradicate.
Using a bulldozer abandoned by the Air Force, he spent two years and
great effort pushing boulders into a single word.

It can be seen from 10,000 feet, silhouetted against the snow.
Government officials exchanged memos full of circumlocutions (no Latin
equivalent exists) but failed to word an appropriation bill for the
destruction of this cairn, that wouldn't alert the press and embarrass
both Parliament and Party.

It stands today, a monument to human spirit. If life exists on other
planets, this may be the first message received from us.
-- The Realist, November, 1964.

pansz

unread,
Nov 21, 2011, 10:23:05 PM11/21/11
to vim...@googlegroups.com
2011/11/22 Tony Mechelynck <antoine.m...@gmail.com>:

> - for X11 (compiled with +xim)
>        :help mbyte-XIM
> - for all versions (compiled with either of the above)
>        :help 'imactivatekey'
>        :help 'imcmdline'
>        :help 'imdisable'
>        :help 'iminsert'
>        :help 'imsearch'
>

Does this work for console vim (with +xim present)? I've tried
'imdisable' and it does not seem to work.

Tony Mechelynck

unread,
Nov 21, 2011, 11:45:40 PM11/21/11
to vim...@googlegroups.com, pansz

The problem with the console is that it intercepts what you type and
then passes it to the application (Vim), possibly after some
translation, or maybe doesn't pass it at all. This additional layer
between the keyboard and the editor means that the _terminal_ may be
trying to interact with the XIM and pass the "cooked" keystrokes to Vim.

For such complex keyboard interaction, I recommend gvim, because it has
much better control over keyboard input, and also over output since you
can set any suitable font by means of 'guifont' without even leaving
Vim. With gvim, there is no ambiguity: the application with which the
XIM interacts can only be Vim, there is no terminal which the XIM could
see as its "opposite number", to which it would be "talking".


Best regards,
Tony.
--
"I have made mistakes but I have never made the mistake of claiming
that I have never made one."
-- James Gordon Bennett

alick oahz

unread,
Nov 21, 2011, 9:51:09 PM11/21/11
to vim...@googlegroups.com

I guess the best way is to use vimim plugin. You can find it here:
http://www.vim.org/scripts/script.php?script_id=2506
It can wipe out the pain of having to switch the input method often.
It also support insert CJK chars while doing search (?/).

Well, here are some possible disadvantages IMHO. When you use the cloud
input engine, the latency is much depended on your network. When you use
the local vocabulary database, the local database can be huge. After
all, vimim is a whole different input method (designed for vim).

Personally I also don't know how to make Vim and IBus Chinese input
method. So other better solutions are appreciated.

--
alick
Fedora 14 (Laughlin) user
https://fedoraproject.org/wiki/User:Alick

pansz

unread,
Nov 22, 2011, 2:46:19 AM11/22/11
to vim...@googlegroups.com
2011/11/22 alick oahz <alic...@gmail.com>:

> I guess the best way is to use vimim plugin. You can find it here:

This still does not solve the problem when you use console vim.
because the XIM is always there. and now you've got 2 different IM.

vimim can be more useful if you can completely disable system XIM when
you're in vim, but you can only disable XIM for gvim.

alick

unread,
Nov 22, 2011, 3:23:18 AM11/22/11
to vim...@googlegroups.com

Oh I cannot see the problem. I think maybe that's because my console
vim has no support of XIM. I use the console vim from Fedora repo,
in it :verbose gives me '-xim'.

Reply all
Reply to author
Forward
0 new messages