Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed the Better Python Console-Plugin for gedit and I am happy with it when I view python code. But I would like to be able to execute some different languages source codes when I have opened it in gedit.

For example, I would like to run $ g++ filename.cpp -o filename.out; ./filename.out if I hit F5 while I have opened a C++-file. If I have opened a PHP-file I don't want to happen anything at all.

Is this possible?

share|improve this question
I see that you've asked two questions but only voted once. If you accept an answer you probably find it useful, then you should also upvote it. – N.N. Aug 24 '11 at 19:06
up vote 0 down vote accepted

This can be done with the external tools in gedit. They're found under Tools.

Create a new external tool and paste the following code into it:



Then bind a Shortcut Key, in your case F5, to this tool.

And, finally press the three dots in the lower right corner (right of Applicability) and choose an option so that it only applies to C++ files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.