You are not logged in.

#1 2011-05-01 22:19:53

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

vim, X11, kbd layout

To use additional language in vim I can, say, use in ~/.vimrc:

set keymap=russian-jcukenwin
set iminsert=0

OTOH, for the same purpose in X11 I have in /etc/X11/xorg.conf.d/10-evdev.conf"

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbLayout"  "us, ru"
        Option "XkbOptions" "grp:menu_toggle, grp_led:scroll"
EndSection

For cases vim is used under X11 I'd want to have the only way (in particular - X11's one) for layout switching. Is it possible?


"I exist" is the best myth I know..

Offline

#2 2011-05-02 13:40:46

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

Re: vim, X11, kbd layout

I see, all archers-vimmers use English only wink

It seems like vim uses symbols rather keyboard scancodes to process commands (and it is definite architecture flaw - probably just historical). As a result, there isn't transparent system-wide (and the only) way to deal with languages in vim under X11 . Am I right??


"I exist" is the best myth I know..

Offline

#3 2011-05-03 02:08:19

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: vim, X11, kbd layout

I'm not a vim expert and I have just started exploring vim key-mappings.  I can point you to helpful (or not) tutorials.

Vim has some defined keyboard key names (http://vimdoc.sourceforge.net/htmldoc/i … #%3CNul%3E).  The Menu key doesn't appear to be one of them.  You should be able to map the Menu key when you are typing the map command by using the keystrokes "Ctrl-V", then "Menu ".  This will put the escape code for the Menu key into the statement.

A short, English tutorial on Vim key-mapping is here: http://www.linux.com/archive/feed/54936.
A more complete English tutorial on key mapping is here: http://vim.wikia.com/wiki/Mapping_keys_ … 8Part_1%29.

You may have to surround your script with tests for the terminal or terminal emulator: "if $TERM=xterm... elseif $TERM=linux..."  In my linux terminals the Menu key is not recognized by Vim, in xterm it is recognized.

Offline

#4 2011-05-03 05:19:50

OrangeMediumGreen
Member
Registered: 2008-11-17
Posts: 16

Re: vim, X11, kbd layout

Do you use gvim under X? You could use .gvimrc to set another layout then.

Offline

#5 2011-05-03 07:48:59

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

Re: vim, X11, kbd layout

@thisoldman

Thanks for the refs. And I'm more saying about system-wide switching. I mean there is the only state of current layout in, say, terminal and in vim's insert (in all buffers/tabs/windows) and cmdline modes.

@OrangeMediumGreen

vim


"I exist" is the best myth I know..

Offline

#6 2011-05-03 11:08:41

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: vim, X11, kbd layout

I think this is what you are asking:

  1. Is there a test for the current Xkblayout?

  2. How do I start vim with the same keyboard setting?

An AUR package, xkblayout-state at https://aur.archlinux.org/packages.php?ID=33298, may help you with the first question.

I'm using the us(USA) keyboard only, so I haven't tested the program thoroughly.  My limited test of it shows it works.

Offline

#7 2011-05-06 22:14:56

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

Re: vim, X11, kbd layout

It seem the behaviour which I treat as expected and natural, isn' such for all others smile And, of course, my English is far from to be perfect.

OK, let's try by example. Say, we have few apps opened: firefox (typing in text area), claws-mail (composing new message), geany (editing some file).. From "vim's POV" they all are in insert mode. OTOH, their commands don't clash with text input: at case not-qwerty layout is selected Ctrl-F will still try to find something. So, expected (by me) vim's behaviour is: current kbd layout does matter at insert and cmdline modes only. At, say, normal mode commands are processed independently of selected (I mean Option "XkbLayout"  "us, ru"; Option "XkbOptions" "grp:menu_toggle, grp_led:scroll") layout.

Is my intention more clear now? smile


"I exist" is the best myth I know..

Offline

#8 2011-05-06 22:48:02

codeRage
Member
Registered: 2011-02-20
Posts: 29

Re: vim, X11, kbd layout

@student

You probably know more about this than I do, but if it helps I use loadkeys to remap Ctrl -> CapsLock in the console, and xmodmap to remap them under X11.

http://tldp.org/HOWTO/Keyboard-and-Cons … TO-15.html
http://linux.die.net/man/1/loadkeys

So if you want a russian language option in console vim then maybe try loadkeys. Put the line in your /etc/rc.local or something. This will also apply to your terminal so I'm not sure how this affects you or if it does at all. Like was suggested before, maybe you would have a "translator" key to switch between the two keymaps. That would be cool. Also a nice prank, since you're typing typing typing and now everything is russian big_smile

Offline

#9 2011-05-06 22:49:39

codeRage
Member
Registered: 2011-02-20
Posts: 29

Re: vim, X11, kbd layout

Real men use nano

Offline

Board footer

Powered by FluxBB