I'm using Vim under Debian, Win Vista and WinXP (the latter two with Cygwin).

To handle tabs more easily, I mapped <C-Left> and <C-Right> to :tab(prev|next). This mapping works like a charm on the Debian machine.

On the Windows machines, however, pressing <C-Left> deletes 5 lines, as far as I can tell, and meddles with cursor position, while <C-Right> does this, too, and additionally enters Insert mode.

Question: To put it in a nutshell, how can I find out, why Vim behaves as it does? Is there a way to backtrace the active commands and keystrokes? Could there be a plugin the culprit? (I didn't install one, perhaps a default include by the Cygwin distro...) If so, how can I find it?

Edit 1: OK, it seems, that I got a first trace: The terminal sends for <C-Left> '^[[1;5D', and for right '^[[1;5C' (evaluated with the <C-V><C-Left> trick). If vim interprets this literally and discards the first characters, it explains the strange behaviour. Any ideas, how I could change this key mapping?

Additional Diagnosis:

  • This behaviour occurs regardless of any existing ~/.vimrc file (is therefore not related to my above mentioned mapings) and is not inherited of some /etc/vim/vimrc, since this doesn't exist in the default Cygwin installation.

  • :verbose map doesn't yield any new insights. Either nothing or my mentioned mappings appear, based on the existence of the .vimrc file

  • :help <C-Left> suggests, that the default would be a simple cursor movement, which is apparently not the case.

  • Vim's version under Cygwin:

    VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 11 2010 17:36:58)
    Included patches: 1-264
    Compiled by http://cygwin.com/
    Huge version without GUI.  Features included (+) or not (-):
    +arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
    -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
    +cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
    +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
    +float +folding -footer +fork() -gettext -hangul_input +iconv +insert_expand
    +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
    +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec -mouse_gpm
    -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
    +multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +postscript
    +printer +profile -python +quickfix +reltime +rightleft -ruby +scrollbind
    +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary
    +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
     -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
    +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
     -xterm_clipboard -xterm_save
       system vimrc file: "$VIM/vimrc"
         user vimrc file: "$HOME/.vimrc"
          user exrc file: "$HOME/.exrc"
      fall-back for $VIM: "/usr/share/vim"
    gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -D_FORTIFY_SOURCE=1
    Linking: gcc   -L/usr/local/lib -o vim.exe       -lm -lncurses  -liconv
  • I switched to mintty now, where <C-Left> still sends ^[[1,5C, but is somehow translated to the correct vim statement. – Boldewyn May 5 '10 at 6:51

:map with no parameters will show what you have mapped inside vim. Any keyboard mapping outside that (as from Keyboard Remap in the Kernel Tools package) will take before vim "sees" the keystroke and thus, obviously, vim can't interpret the original.

  • So, :verbose map and :help <some-keystroke> are sufficient to find out the function of every key in vim? – Boldewyn May 5 '10 at 6:53
  • Try it and find out. Function keys sometimes do not have common ways of mapping; that's hardware dependent. – mpez0 May 5 '10 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.