1

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.

2
  • 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
    Commented Feb 16, 2017 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
    Commented Feb 16, 2017 at 23:35

1 Answer 1

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

2
  • 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
    Commented Feb 17, 2017 at 11:09
  • 1
    @Jonas Added. Thanks for additional information!
    – Alex
    Commented Feb 17, 2017 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .