1

I have a bind that invokes vim on a file with a search term:

This is shell scripting. vim $FILE "+/$SEARCHTERM"

The problem that happens is that only if $SEARCHTERM appears just once in a file, it seems to be emitting search hit BOTTOM, continuing at TOP and this is presumably causing the opening of the buffer to be interactively delayed with Press ENTER or type command to continue.

I just want this not to happen to make the file open to the search term for me immediately.

  • 1
    I can't reproduce this behaviour. vim some/file '+/some-term' works fine for me even if some-term only occurs once. Can you try with vim -Nu NONE? Or vim "$FILE" '+exec "norm /" . $SEARCHTERM . "\<cr>\<cr>"', if $SEARCHTERM is exported? – muru Feb 2 '18 at 6:16
1

Providing the argument "+silent /${SEARCHTERM}" to vim was my solution. This should be equivalent to running the :/ search using :silent / which does the trick. No need to change how vim normally behaves with searches!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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