I am not able to create a mapping for the <xxx> key. What is wrong?

1) First make sure, the key is passed correctly to Vim. To determine if this is the case, put Vim in Insert mode and then hit Ctrl-V (or Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on Windows if you are using the mswin.vim script file) followed by your key. If nothing appears in the buffer (and assuming that you have ‘showcmd’ on, ^V remains displayed near the bottom right of the Vim screen), then Vim doesn’t get your key correctly and there is nothing to be done, other than selecting a different key for your mapping or using GVim, which should recognise the key correctly. 2) Possibly, Vim gets your key, but sees it as no different than something else. Say you want to map Ctrl-Right, then in Insert mode hit Ctrl-K followed by Ctrl-Right. If Vim displays <C-Right> it has correctly seen the keystroke and you should be able to map it (by using <C-Right> as your {lhs}). If it displays <Right> it has seen the keystroke but as if you hadn’t held Ctrl down: this means your temrinal passes Ctrl-Right as if it were just <Right>. Anything else means the key has been misidentified. 3) If the key is seen, but not as itself and not as some recognizable key, then there is probably an error in the terminal library for the current terminal (termcap or terminfo database). In that case

        :set term?

will tell you which termcap or terminfo Vim is using. You can try to tell vim, what termcode to use in that terminal, by adding the following to your vimrc:

        if &term == 

            set =

        endif

where <termname> above should be replaced by the value of ‘term’ (with quotes around it) and <keycode> by what you get when hitting Ctrl-V followed by Ctrl-Right in Insert mode (with nothing around it). <C-Right> should be left as-is (9 characters). Don’t forget that in a :set command, white space is not allowed between the equal sign and the value, and any space, double quote, vertical bar or backslash present as part of the value must be backslash-escaped. Now you should be able to see the keycode corresponding to the key and you can create a mapping for the key using the following command:

        :map   

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind