IdeaVim and russian layout
Asked Answered
M

4

13

Is there any way to make IdeaVim understand russian layout in modes other than Input? In my .vimrc I have

set keymap=russian-jcukenwin

so I can switch languages in VIM by pressing Ctrl+^ and relatively happy with that. But it seems that IdeaVim doesn't read or understand this setting. It can be very annoying to stop typing something (for example comment) in russian, switch to command mode and stuck. Is there any workaround?

Mcbrayer answered 28/7, 2013 at 5:14 Comment(0)
M
17

First i tried to use langmap like in this gist but IdeaVim does not support langmap.

Next I tried to use map so I made this solution:

let rumap = 'йцукенгшщзхъфывапролджэёячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'
let enmap = 'qwertyuiop[]asdfghjkl;''\zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>' 
let mapLen = strchars(rumap)
let i = 0
while i < mapLen
    let ruChar = matchstr(rumap, ".", byteidx(rumap, i))
    let enChar = enmap[i]
    "echo 'map '.ruChar.' '.enChar
    execute 'map '.ruChar.' '.enChar
    execute 'cmap '.ruChar.' '.enChar
    let i += 1
endwhile

map Ё \|
cmap Ё \|

You can customize it for your keyboard layout.

But I forgot that IdeaVim does not support vimscript and cmap and I added echo 'map '.ruChar.' '.enChar (commented line), appended code from above to .vimrc and opened vim from command line so it printed me all map commands. I added them to .ideavimrc and appended mapping of pipe (|) character:

map й q
map ц w
map у e
map к r
map е t
map н y
map г u
map ш i
map щ o
map з p
map х [
map ъ ]
map ф a
map ы s
map в d
map а f
map п g
map р h
map о j
map л k
map д l
map ж ;
map э '
map ё \
map я z
map ч x
map с c
map м v
map и b
map т n
map ь m
map б ,
map ю .
map Й Q
map Ц W
map У E
map К R
map Е T
map Н Y
map Г U
map Ш I
map Щ O
map З P
map Х {
map Ъ }
map Ф A
map Ы S
map В D
map А F
map П G
map Р H
map О J
map Л K
map Д L
map Ж :
map Э "
map Я Z
map Ч X
map С C
map М V
map И B
map Т N
map Ь M
map Б <
map Ю >
map Ё /|

Now I have IdeaVim working with cyrillic layout in normal, visual+select and operator-pending modes.

Madgemadhouse answered 18/7, 2015 at 13:35 Comment(3)
Thanks, it works for me! Well, almost. I realized that combinations like ciw or daw still do not work. Looks like i and a are not handled correctly when used as 'inside' and 'around'. Any ideas how this can be fixed?Sanborn
These combinations do not work for me too :( I've not found solution yet. If you will then please post it here.Madgemadhouse
Thanks a lot! I'd added that the encoding should be ANSISchreibman
P
3

You can install Fcitx and IdeaVimExtension.

Add the following line to your ~/.ideavimrc:

set keep-english-in-normal-and-restore-in-insert

IDE will switch to English in normal mode and restore the previous input language in insert mode.

Installing and configuring Fcitx on Ubuntu Gnome (Fcitx - ArchWiki):

  1. Install with sudo apt install fcitx
  2. Create ~/.pam_environment file with the following contents:
XMODIFIERS DEFAULT=@im=fcitx
GTK_IM_MODULE DEFAULT=fcitx
QT_IM_MODULE DEFAULT=fcitx
  1. Add a startup application:

fcitx startup program

  1. Install Input Method Panel Gnome extension.

For Vim you may want to install fcitx.vim plugin.

Propertius answered 1/12, 2019 at 11:1 Comment(0)
K
0

Привіт! The short answer is no, there is no workaround. Unless you are willing modify IdeaVim.

When a key is pressed, one can get different information about the event. For our case, the most interesting pieces are hardware key code, and key value. The former is identical for s, ы, and і, which are located on the same key; the latter differs from layout to layout. Since IdeaVim uses key values for bindings (and in the settings actions are also bound to key values), it isn't possible to trigger actions while using a layout where the key value is different. As a consequence, it will work well in a German layout, for example.

I would recommend you to avoid writing comments in Russian anyways.

Koerner answered 1/10, 2014 at 17:16 Comment(0)
M
0

Problem on Windows.

Your .ideavimrc file has to be same encoding as your project files.

In my case IdeaVim created .ideavimrc with windows-1251 encoding when my project files was with UTF-8. And config wasn't working. I changed encoding, reloaded Rider and it has finally applied.

Matilda answered 5/7, 2023 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.