<p>I was inspired by this thread:</p>
<p><a href="http://ubuntuforums.org/showthread.php?t=330145" rel="nofollow">Compiling and running straight from gedit</a></p>
<p>I like this solution because the beginner does not need to learn <strong>vim</strong> or <strong>emacs</strong> before starting to program.
<strong>gedit</strong> <em>(gnome-edit)</em> is dead simple to use for most beginners who like pointing, clicking, cutting and pasting. Nonetheless, <strong>gedit</strong> does have <em>syntax highlighting</em> and <em>parenthesis-matching</em> (you need to turn bracket-matching on in your prefs.); certainly features that no programmer should do without. (Pity the poor Windows noobs who use <em>Notepad</em>). Further, <strong>gedit</strong> DOES have the ability for one click compiling and running -- it's just implemented in user scripts. So -- I explain the script system and provide some samples. After this you have a development environment that a beginner can use. I do assume that you are helping your beginner set this up.</p>
<ol>
<li>Click <em>Edit\Preferences</em>, go to <em>Plugins</em> tab, and enable <strong>External Tools</strong>. </li>
<li>Go to <em>Tools\External Tools</em> and select <em>New</em>. A window will open with description <em>A Brand New Tool</em>. </li>
<li>Go down to the command and type <strong>echo Hello!</strong>. </li>
<li>Now when you execute <em>Tools\New Tool</em> you will see <em>Hello!</em> in your <em>Shell Output</em> window.</li>
<li><strong>cd ~/.gnome2/gedit/tools; ls</strong></li>
<li>You will see one or more scripts labeled <em>new-tool</em></li>
<li>You can copy and edit these scripts to create new commands. Clearly you can do this through the interface mentioned in step 4, but you can't configure everything with that interface. In particular, you can't change the tool name, so that all your tools are called <em>new-tool</em> in the pull-down menu.</li>
<li>To create your first script, which will execute a program in your root directory,<br>
<strong>cp new-tool execute</strong> in the directory you changed to in step 5.</li>
</ol>
<p>Here is my <em>execute</em> script.</p>
<pre><code># [Gedit Tool]
# Comment=Execute from current directory
# Input=nothing
# Name=Execute
# Shortcut= Control>x
# Applicability=all
# Output=output-panel
echo -e "\nExecuting..." ;./${GEDIT_CURRENT_DOCUMENT_NAME%.*}
</code></pre>
<p>Here is my script called *CCompile_and_Execute*.</p>
<pre><code># [Gedit Tool]
# Comment=C-Compile and Execute
# Input=nothing
# Name=C Compile and Execute
# Shortcut= Control>c
# Applicability=all
# Output=output-panel
echo -e "Compiling... \n"
echo "gcc $GEDIT_CURRENT_DOCUMENT_NAME -o${GEDIT_CURRENT_DOCUMENT_NAME%.*}"
gcc $GEDIT_CURRENT_DOCUMENT_NAME -o${GEDIT_CURRENT_DOCUMENT_NAME%.*}
echo -e "\nExecuting..."
./${GEDIT_CURRENT_DOCUMENT_NAME%.*}
</code></pre>
<p>A couple of notes:</p>
<ol>
<li>These are ordinary <em>bash</em> scripts, but they have access to
special environment variables (like GEDIT_CURRENT_DOCUMENT_NAME)
and there are other special variables. </li>
<li>The comment lines in the scripts are actually recognized by <em>gedit</em>.</li>
<li>Should you wish to use a different compiler, just change <em>gcc</em> to <em>g++</em>, or whatever.</li>
<li>Now that you know how to directly edit these script files, you can add custom commands galore to <em>gedit</em>.</li>
</ol>