VIM comma is missing in insert mode

Tag: vim Author: hackersend Date: 2009-07-21

I'm a VIM beginner, and I have a weird problem. I started using vim in a terminal emulator, but today I moved to gVim. Then I realized that I cannot write a comma in Insert mode! I tried :map ,, :imap , both said no mapping found. THen I tried :nomap , and :inomap , both without any luck. As writing the commands, I am able to write the comma, but not in insert mode. What can be the problem?


Some details: I'm running a freshly installed ubuntu 9.04 system, with an english keyboard, but using a hungarian layout. I am able to write a comma in vim when writing into the "command line" of vim, after pressing : in command mode.

Do you have a vimrc file? This is ~/.vimrc in UNIX, or C:\Documents and Settings\(user name)\_vimrc in Windows. This file might be configuring incorrect keymappings for GUI mode. Failing that, do you have an unusual keyboard layout?
Yes, I have a vimrc. There are no mappings in it (and :map , would print it, wouldn't it?). And yes, I do have an unusual keyboard layout, it's a hungarian keyboard. That said, I still am able to write the comma into the "command line" (after hitting :).

Other Answer1

remove the 'cindent' line from your .vimrc file. worked for me!

comments:

This solved it for me.

Other Answer2

What happens if you type CTRL-V followed by a comma in insert mode? Do you get a comma?

Also, since you only have this problem in gvim and not vim, try running xev and typing , into it to see if the events look odd. (you may need to apt-get install x11-utils for xev) The events I get look like this:

KeyPress event, serial 30, synthetic NO, window 0x4000001,
    root 0x236, subw 0x0, time 788140933, (138,120), root:(144,139),
    state 0x10, keycode 59 (keysym 0x2c, comma), same_screen YES,
    XLookupString gives 1 bytes: (2c) ","
    XmbLookupString gives 1 bytes: (2c) ","
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x4000001,
    root 0x236, subw 0x0, time 788141013, (138,120), root:(144,139),
    state 0x10, keycode 59 (keysym 0x2c, comma), same_screen YES,
    XLookupString gives 1 bytes: (2c) ","
    XFilterEvent returns: False

comments:

On this system, the problem exists with vim as well (I started learning vim on my old arch linux, which I recently changed to ubuntu, and started using gvim). This is my xev output: pastie.org/574928 It looks OK. Visual block mode and pressing comma doesn't work either.
CTRL-V in insert mode does a verbatim insert of the next character you type. CTRL-V goes into visual-block mode only if you were in normal (not insert) mode to begin with.

Other Answer3

Ok, I managed to solve it. Previously I used mkvimrc to generate my .vimrc. Now, I deleted it all, and created one manually. Not sure what caused it, but now it works as expected. Moral: don't be lazy, write your vimrc yourself. :)

comments:

I had similar problem and it looks that it was caused by enabled cindent in configuration.
The 'remove cindent' comment below solved the problem for me.

Other Answer4

Do you have something like this in your .vimrc set cinkeys=0{,0},:,0#,!,!^F? I run into this issue and solved it by removing the rogue exclamation mark set cinkeys=0{,0},:,0#,!^F