Friday, March 12, 2010

How to enable Compile and Run for C/C++ files in gedit

I never liked using gedit for programming because it needed extensive customization before it even came close to becoming a programming editor. However, those that are just starting out with linux will feel most at home in gedit. So here is how to enable "Compile and Run" functionality in gedit.

1. Enable the External Tools plugin by going to Edit -> Preferences -> Plugins as shown in the screenshot below

2. Go to Tools -> Manage External Tools and create a new Tool by clicking on the "new" icon near the Help button.

3. Name the new tool "Compile and Run" and press enter
4. In the coding area, paste the following script:

#!/bin/sh
cd $GEDIT_CURRENT_DOCUMENT_DIR
g++ -Wall -g $GEDIT_CURRENT_DOCUMENT_NAME && xterm -e "sh -c './a.out; echo Press enter to quit... && read KEY'"

5. Put in a shortcut key (eg. Ctrl + F5) in the shortcut key area
6. Set the save setting to Current Document
7. In the applicability setting, select C and C++

That's it. You're done! Press Ctrl + F5 to start off with compile and run. Happy coding!

PS: All the tools to make gedit programming worthy can be found in the blog posts here:
http://www.makeuseof.com/tag/top-plugins-to-extend-and-make-gedit-a-more-useful-text-editor-linux/
http://www.micahcarrick.com/09-29-2007/gedit-html-editor.html

5 comments:

  1. Add zing to the special occasions of your acquaintances in Agra by sending our fantastic flowers and tasty cakes. Our expert team affords excellent customer service support for the delivery of our flowers and cakes to Agra. Our supreme delivery networks all over Agra, Same day delivery option to Agra and punctual delivery of flowers and cakes to Agra have helped us to be more proficient. Moreover sending flowers and cakes to Agra online with us is 100% secured.

    Please visit:
    www.agrafloristshop.com

    ReplyDelete
  2. Anonymous1:00 PM

    Send your good taste to celebration by delivering our mouthwatering cakes to Dehradun and exotic flowers to Dehradun and leave a cherished memory with them. Add zing to the special occasions of your acquaintances in Dehradun by sending our fantastic flowers and tasty cakes.

    Please visit:
    www.dehradunfloristshop.com

    ReplyDelete
  3. Your view is very good.

    ReplyDelete
  4. Your blog is very good.

    ReplyDelete