Take the 2-minute tour ×

Sometimes I use vim to write non-US text, and when I wanna use any command in normal mode, I need to change layout to US. It's possible to do that automaticly?

PS. I can do mapping like this, but in this case command looks like :ц instead :w - not pretty and typo-risk.


I don't want to use keymap option, because I prefer switch languages by CapsLock. I've try to write autocmd for InsertLeave event, but failed...

Update 2

Probably anybody know, why the following not work?

function SetUsLayout()
  !setxkbmap us,ru

autocmd InsertLeave * call SetUsLayout()
share|improve this question
The answer here is relevant: stackoverflow.com/a/3777557/329063 –  glts Jun 11 '12 at 17:37
See my answer to a similar question "Vim “annoyance” with keyboard layouts" rather than the one linked in the previous comment, since it covers effectively the same issue and it is more thorough. –  ib. Jun 12 '12 at 3:21
I already write in Update, that don't want to use keymap option, because it's not possible to map CapsLock in vim. –  Kulti Jun 12 '12 at 8:01
add comment

2 Answers

:help langmap

is likely to provide all the info you need.

share|improve this answer
"Characters entered in Command-line mode will NOT be affected by this option." So hjkl works fine, but commands not. –  Kulti Jun 11 '12 at 16:58
This deals with what you asked for: normal mode commands. See :help keymap for the command mode. –  romainl Jun 11 '12 at 17:06
Ok, I can set keymap=russian-jcukenwin, but to switch to US I need to use ctrl+^ (or map any other), but not very convenient CapsLock. –  Kulti Jun 11 '12 at 18:15
I'm not really in a position to test it out (french layout) but you could try something like :nnoremap : :<C-^>. What's the deal with CapsLock? –  romainl Jun 11 '12 at 18:58
stackoverflow.com/a/2176558/656610 At now I try to use OS-dependent solution: setxkbmap to switch layout automaticly on InsertLeave event –  Kulti Jun 11 '12 at 19:09
show 1 more comment
up vote 0 down vote accepted

Looks like, that cross-platform solution doesn't exist... So, under KDE I use the following:

function! SetUsLayout()
  silent !qdbus org.kde.keyboard /Layouts setLayout us > /dev/null

autocmd InsertLeave * call SetUsLayout()
share|improve this answer
add comment

Your Answer


