V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
scola
V2EX  ›  Linux

怎么在vim在normal 模式下自动禁用 中文

  •  
  •   scola · Oct 12, 2013 · 6064 views
    This topic created in 4592 days ago, the information mentioned may be changed or developed.
    当我在vim 插入模式下 输入中文,
    切换到 normal模式下操作,此时还是中文,命令都运行不了,
    还要手动切换,特别麻烦
    怎么在vim在normal 模式下自动禁用 中文啊
    我使用的ibus google pinyin ,可以使用shift 切换 中英文
    大侠们支支招。
    16 replies    1970-01-01 08:00:00 +08:00
    jiazhoulvke
        1
    jiazhoulvke  
       Oct 12, 2013   ❤️ 2
    aufula
        2
    aufula  
       Oct 12, 2013
    你输完中文怎么换回normal模式,难道不是先切到英文么?
    Aben
        3
    Aben  
       Oct 12, 2013 via iPhone   ❤️ 1
    yetone
        4
    yetone  
       Oct 12, 2013
    @aufula ESC
    scola
        5
    scola  
    OP
       Oct 12, 2013
    @jiazhoulvke 我使用的ibus 输入法 不知道能不能用那个

    @Aben 刚才试过了,好像不行,
    painter
        6
    painter  
       Oct 12, 2013
    vim怎么在normal 模式下自动禁用 中文
    scola
        7
    scola  
    OP
       Oct 12, 2013
    @painter 老兄跟我有同样的需求?
    ybian
        8
    ybian  
       Oct 12, 2013
    参考 /t/45772
    不过我那个小程序只在 Mac 下有用,但是改成 Linux 的应该不难。
    Micky
        9
    Micky  
       Oct 12, 2013
    用gvim吧
    normal下自动禁用中文。。我忘记是要专门设置还是怎样 反正我现在gvim就是这样的
    aufula
        10
    aufula  
       Oct 12, 2013   ❤️ 1
    有个挫一点的办法
    au insertLeave :!pkill ibus-daemon<cr>
    au insertEnter :!ibus-daemon &<cr>
    lilydjwg
        11
    lilydjwg  
       Oct 12, 2013
    @jiazhoulvke 哇哇,你在这里一贴链接,我那文章就 20 多个访问呢~
    lilydjwg
        12
    lilydjwg  
       Oct 12, 2013   ❤️ 1
    @aufula 你这…………ibus 可以通过 dbus 关闭和开启的,vim_dev 邮件列表曾经有人给过一个示例。
    scola
        13
    scola  
    OP
       Oct 12, 2013
    @aufula 这个我加入到 .vimrc 好像还是不行呢
    aufula
        14
    aufula  
       Oct 13, 2013   ❤️ 2
    @scola
    @lilydjwg

    function! OnInsertLeave()
    python << EOT
    import ibus
    ff = ibus.bus.Bus()
    ibus.inputcontext.InputContext(ff,ff.current_input_contxt()).disable()
    EOT
    endfunction
    au InsertLeave * :call OnInsertLeave()
    scola
        15
    scola  
    OP
       Oct 13, 2013
    @aufula 这次真的可以了,太感谢了。
    这个退出到normal 是直接关闭ibus。不知有没有方法 把 disable 换成 switchtoenglish 就完美了
    congeec
        16
    congeec  
       Dec 18, 2013
    se imd
    au InsertEnter * se noimd
    au InsertLeave * se imd
    au FocusGained * se imd

    note: only available when compiled with +xim
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2933 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 11:45 · PVG 19:45 · LAX 04:45 · JFK 07:45
    ♥ Do have faith in what you're doing.