3

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?

9
  • 3
    Does <C-r>=1+2<CR> work?
    – romainl
    Jan 13, 2013 at 15:50
  • Instead of <Return>, could you try <CR>, which executes what was before it. Also try what @romainl said.
    – greduan
    Jan 13, 2013 at 16:29
  • 3
    Does the output of ":set cpo?" (with the ? as part of the command) include "<" and/or "k"?
    – Heptite
    Jan 13, 2013 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, 2013 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, 2013 at 17:25

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .