1

So i have following small test case

vnoremap <silent> d :<C-u>call Test()<cr>
vnoremap <silent> e :<C-u>call Test2()<cr>
fun! AskUser()
    let v = input('is this really ok with you? (y/n) ')
    redraw
    return v
endfun

fun! Test() range
    call AskUser()
    if 1
        echo 'hi hi hi'
        echo 'hi hi hi'
    endif
endfun

fun! Test2() range
    call AskUser()
    echo 'hi hi hi'
    echo 'hi hi hi'
endfun

So can anyone explain why visual mode d keybinding fails to show any message at all while e keybinding works without problem

Note the problem is not related to keybinding at all but to a fact that there is if statement after call to input function

I've tested it on MacVim and terminal vim on linux on latest vim versions compiled from mercurial source code and all have this problem

UPDATE: Some ppl didn't understood what the problem is. Well to be explained in details when you hit d in visual mode you get a input prompt and when you answer it you don't see any messages in command line while when you hit e and answer the prompt you see message hi hi hi twice in a row and 'Press ENTER or type command to continue' message

5
  • Both echo messages are printed with VIM - Vi IMproved 7.3 in Linux. Commented Sep 27, 2012 at 12:47
  • some ppl say you can if it works for you u can reproduce the problem by running vim -N -u none Commented Sep 27, 2012 at 12:48
  • Both print the hi hi hi for me with GVIM 7.3.000; please state the full version (inclusive patch number) instead of latest; patches are posted almost daily. Commented Sep 27, 2012 at 13:30
  • VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 26 2012 17:32:05) Included patches: 1-672 Commented Sep 27, 2012 at 13:37
  • And this MacVim VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 2 2012 17:38:47) MacOS X (unix) version Included patches: 1-390 Commented Sep 27, 2012 at 13:38

1 Answer 1

1

I don't know the reason of that different behaviour but testing I realised that if the function ends with the conditional if and last sentence is the endif, then messages are not showed in screen.

I've created a custom vimrc only with your code and I have run it with vim -N -u new-custom-vimrc infile. Like that, I can reproduce the behaviour of the question, but it seems to work when I avoid the endif as last sentence of the function, like:

fun! Test() range
    call AskUser()
    if 1
        echo 'hi hi hi'
        echo 'hi hi hi'
    endif
    let dummy = 1 
endfun

Also works this:

fun! Test() range
    call AskUser()
    if 0
        return
    endif
    echo 'hi hi hi'
    echo 'hi hi hi'
endfun
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.