0

My current setup to develop is a terminal to execute my code and multiple vim sessions in which I write my code.

Since I constantly work on smaller functions and compile/execute them frequently I often have to switch to the terminal just to run my code and see the current output.

Is there a way I to set a hotkey to execute the last command (compile and execute) in the terminal while staying with the cursor in the vim window?

I run Ubuntu and use the i3 windows manager.

  • May be I misread your question, but if you hit "Up" arrow on the keyboard when you are in terminal window, it will restore in command line previously executed command. You can hit it multiple times to see more commands from history – Alex Feb 16 '17 at 23:29
  • The problem is, that I have to switch to the terminal for this. I want to execute the terminal command while being in the vim window. I update my question – Natjo Feb 16 '17 at 23:35
1

You can use key mapping

:map <F9> @:

It will repeat last executed command.
Run your command with :! ProgramYouWantToRun > /dev/pts/X

Where right X is the terminal you want.
This X can be obtained by running tty command in the terminal where you want to execute your code.

When you press F9 it will repeat execution :! ProgramYouWantToRun > /dev/pts/X

P.S.

More on key mapping in vim you can find here

  • This in combination with this kind of command: :! ProgramYouWantToRun > /dev/pts/X where X is the terminal you want. I find the right X by running tty in the terminal I want to execute my code. Maybe you update your answer with this additional information. – Natjo Feb 17 '17 at 11:09
  • 1
    @Jonas Added. Thanks for additional information! – Alex Feb 17 '17 at 11:23

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.