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.

I have this bit of magic in .vimrc:

inoremap <Tab> <c-r>=InsertTabWrapper()<Return>
function! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k' 
        return "\<tab>"
    else    
        return "\<c-p>"
    endif   
endfunction

This works fine on all systems that I use it (insert Tab at beginning of line, autocomplete otherwise), however on one system running VIM v7.0.237 the actual text InsertTabWrapper() is inserted into the file instead of running the function. Casual googling leads me to believe that any VIM 7.x version should support function calls like this. So what else might be the issue?

share|improve this question
3  
Does <C-r>=1+2<CR> work? –  romainl Jan 13 '13 at 15:50
    
Instead of <Return>, could you try <CR>, which executes what was before it. Also try what @romainl said. –  Greduan Jan 13 '13 at 16:29
3  
Does the output of ":set cpo?" (with the ? as part of the command) include "<" and/or "k"? –  Heptite Jan 13 '13 at 18:56
    
Thanks. Even <C-r>=1+2<CR> doesn't work (it prints 1+2 to the file). Note that upon pressing <C-r> I do see the expected " character to let me know that I've pressed <C-r>, but upon pressing = it disappears and the following characters are printed to the file. –  dotancohen Jan 14 '13 at 11:56
2  
It looks like the expression register is not available. Do you have +eval in $ vim --version | grep eval? What about :set compatible?? –  romainl Jan 14 '13 at 17:25

1 Answer 1

up vote 2 down vote accepted

So…

The fact that Vim couldn't evaluate an expression as simple as 1+2 suggested that it's unable to use "expressions" as a whole. AFAIK, the only reason for that would be that Vim is not built with the +eval feature.

That's why I asked you to check the presence of +eval in $ vim --version | grep eval.

share|improve this answer

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.