Porcupine Andrew
Porcupine Andrew

Reputation: 192

In VIM, How to avoid hit-enter prompts after executing long command?

I'm writing my vimrc file and do some onoremap like this:

onoremap i@ :<c-u>execute "normal! /\\w\\+@\\w\\+\\.[0-9a-zA-Z.]\\+\r:nohlsearch\rvf@h"<CR>

For this one, I map the i@ to do some operation on "the username of the next email-like string". It works fine in vim window that is large enough. However, when I test it on a relatively small vim window, for example, hit ci@ to quickly change the username of the next email-like string, this execution needs a hit-enter to go on before I can really "change". This is kind of awful since I may frequently do vim things in really small windows.

I believe the hit-enter prompt here was caused by the too long message when executing the search command. I have googled for solution, and I know I can set shortmess flag in vim to make message shorter or increase the height of command line display. But I think these solutions are not essence.

Besides, I don't want to omit the external command line output. Is there some way to totally avoid hit-enter prompts that are caused only by "not enough message space"?

Or is there some way I can change in my onoremap code to meet this need?

Thanks a lot :)

(Google solution: Avoiding the "Hit ENTER to continue" prompts)

Edit: I said "vim window", but actually the problem was not prompted due to a small "window in vim", but "vim in a small terminal display". If you split a small vim window but still with a long message bar, the hit-enter prompt won't occur.

Upvotes: 2

Views: 620

Answers (1)

Matt
Matt

Reputation: 15091

Is there some way to totally avoid hit-enter prompts that are caused only by "not enough message space"?

No. Only "more prompts" can be fully disabled. See :help hit-enter.

I believe the hit-enter prompt here was caused by the too long message when executing the search command.

I guess, not the length but the number of messages: one message for echoing the mapping, and another for / output.

Try to use silent like this:

onoremap <silent>i@ :<c-u>silent! execute ...

The first <silent> suppresses "echo", the second one suppresses the command's output.

Upvotes: 5

Related Questions