David542
David542

Reputation: 110412

Why does this command 'hiccup'?

I have the following filter command:

vnoremap    <silent> <leader>C   :w! !pbcopy<CR><CR>

Yet, when I run it, there is a short 'hiccup', as shown in the video here: https://gyazo.com/ca78c5adfcf4b3b7a6a9f885acb5c8bc. Why does this occur? It seems to be inputing the command 'invisibly' or something (such as the extra command line that often occurs after an input command or echom).

Upvotes: 0

Views: 49

Answers (1)

MarcoLucidi
MarcoLucidi

Reputation: 2177

if you run the command "by hand" you'll see that after the first <CR> (when you press enter the first time, when the command gets executed) vim enlarges the status bar displaying the output of the command and a message that says:

Press ENTER or type command to continue

then you press enter again (the second <CR> in the remap) and the status bar shrinks again. I think the "hiccup" is due to this status bar fast "enlarge and shrink" which causes a screen redraw and is also the reason why you need a double <CR> in the remap.

Upvotes: 1

Related Questions