I have assigned the macro !clear && gcc % && ./a.out to the key 'r'.

So when I press '@r', I expect vim to:

  1. Clear the shell
  2. compile the current C file
  3. run the output

The problem is that it does all three but does not wait at the output screen where it shows "Press ENTER or type command to continue" and comes back to command mode.

  • Please show the exact map command you are using. EDIT: I just saw you use @r so that is a macro and not a map. You have to end the recording of the macro before you press enter at the "hit enter" prompt otherwise that will be part of the macro. (press q before enter). – Lucas Jul 24 '18 at 18:24
  • Indeed, it is a macro. Yes, I quit recording before hitting enter, so that isn't the problem. Any other suggestions? – Apoorve Jul 24 '18 at 18:50
  • For me this works in vim 8.1.22: @r!clear && seq 200<CR>q (I use seq because I don't have your c program and <CR> is the return key here). The I can later type @r and it executes seq again and stops at the hit enter prompt. Did you set more? – Lucas Jul 24 '18 at 19:49
  • I'm sorry, I don't currently have access to the system. I am fairly new to vim so I did not know of the set more command. Will try and confirm. Thanks! – Apoorve Jul 25 '18 at 14:20

Your Answer

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

Browse other questions tagged or ask your own question.