Giter Site home page Giter Site logo

Comments (5)

lyokha avatar lyokha commented on June 25, 2024 1

@coordinatio, ImInsertToggle() looks good except you'd better use setlocal instead set in both clauses to not affect iminsert globally rather than in the current buffer. I also fixed the bug with the dynamic keymap assistance that I'd mentioned.

from vim-xkbswitch.

lyokha avatar lyokha commented on June 25, 2024

Hi.

I wonder, is there a way to switch layout when in normal mode?

Do you mean that Vim would alter some state after triggering system keyboard layout switch? If so, then no: system keyboard layout change cannot be caught inside Vim as it is only caught by the desktop environment.

Occasionally, I realize that I need to switch all key maps to another language when in normal mode.

What kind of key maps do you mean? The plugin does not affect Vim's Normal mode maps in any way, it only may load the Insert mode maps (i.e. imaps) which have no effects in Normal mode.

from vim-xkbswitch.

coordinatio avatar coordinatio commented on June 25, 2024

For example, let's suppose that you need to edit multilingual text like that:

A word in English, а теперь слово на русском.

You have left the insert mode when you were writing the Russian text, you are at the end of the line and need to jump to the beginning of the word English by pressing FE. You cannot do that because of the mappings active. So, you must enter insert mode, switch the layout, exit the insert mode and then if you press FE that will do what you want.

The idea is to avoid that "enter insert mode - exit insert mode" sequence. Would you please recommend how to do that?

from vim-xkbswitch.

lyokha avatar lyokha commented on June 25, 2024

Ok, this looks like an effect of the Keymap assistance in Normal mode. Removing

let g:XkbSwitchAssistNKeymap = 1
let g:XkbSwitchDynamicKeymap = 1

from the Vim's config file should fix this. Or, if you still want to use the keymap assistance, you may reset iminsert by typing

:set iminsert=0

(you can also define a map for this in Normal mode, notice also that the language in the search line can be switched easily by Ctrl-^).

Btw while digging through this issue I found a small bug: when g:XkbSwitchDynamicKeymap is on then both g:XkbSwitchAssistNKeymap and g:XkbSwitchAssistNKeymap is automatically on regardless of their values in the Vim config. I am going to fix this.

from vim-xkbswitch.

coordinatio avatar coordinatio commented on June 25, 2024

Thanks for the advice!
I've made the following change in my .vimrc and it seems like the perfect solution I have been searching for!

function! ImInserToggle()
    if &iminsert
        set iminsert=0
    else
        set iminsert=1
    endif
endfunction
nnoremap <a-k> :call ImInserToggle()<cr>

Thank you so much!

from vim-xkbswitch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.