Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My code

In my vimrc file I have added a key mapping to create new tabs.

map 1 :tabnew<CR>


The problem

However, when I press 1 in vim, it prints the ` variable as a string literal. I will have to press the return key to execute key mapped colon commands.

:tabnew<CR>


Extra Information

I am using PuTTY to connect to my Debian server.

Thank you for helping me.

share|improve this question
    
It's not a variable, it's a special key notation. Do you have the "<" character in the output of ":verbose set cpo?" (with the question mark as part of the command)? –  Heptite Jul 26 '13 at 22:46
    
For that matter, what's the output of ":verbose set compatible?" (again, with the question mark as part of the command)? –  Heptite Jul 26 '13 at 22:47
    
Thank you for replying. Yes it is there in the output. cpoptions=aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ$!%*-+<> Last set from /usr/share/vim/vim72/ftplugin/vim.vim And nocompatible. –  user907560 Jul 26 '13 at 22:47
    
Okay, the < means that the special keycodes will not be recognized in mappings. You either need to make sure you are not running in compatible mode, or manually remove the < from 'cpoptions'. –  Heptite Jul 26 '13 at 22:48
    
Thanks! What would you suggest I do? And how do I change cpoptions? By the way, what do these two things mean? compatible and cpo? –  user907560 Jul 26 '13 at 22:50

1 Answer 1

up vote 0 down vote accepted

For some reason you are running Vim in compatible mode, and if you have a ~/.vimrc it should automatically be going into nocompatible mode. Whatever the reason, I suggest you override it by adding this to your ~/.vimrc:

:set nocompatible

The problem is that in compatible mode, many of Vim's extended feature set is disabled, including recognizing <...> notation in mappings as special key codes.

If doing :set nocompatible doesn't work, try manually setting 'cpoptions' to the Vim non-compatible default:

:set cpoptions=aABceFs

See:

:help 'compatible'
:help 'cpoptions'

(The single quotes are part of the command.)

Edit: From the discussion in comments it appears your Vim install is broken and the system vim.vim ftplugin is overriding the 'compatible' or 'cpoptions' settings. Upgrading from 7.2 to 7.3 may help.

share|improve this answer
    
I am not running compatible mode. The output says nocompatible. –  user907560 Jul 26 '13 at 22:52
    
If you are in nocompatible mode, the output of ":set cpoptions?" should not be including all the stuff you showed above. Something is very messed up. –  Heptite Jul 26 '13 at 22:53
    
Here is my /etc/vim/vimrc file. pastebin.com/W6i9BySv –  user907560 Jul 26 '13 at 22:56
    
Here is my ~/vimrc file. i41.tinypic.com/11w9dl4.png –  user907560 Jul 26 '13 at 23:00
    
It is still not working. –  user907560 Jul 26 '13 at 23:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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