Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 am currently using gedit for two programming projects. One is done with Python, the other one with Java. In the Java project I have to use tabs and in the Python-one I have to use spaces.

Can I configure gedit in a way that I don't have to manually change the tab/space settings?

share|improve this question
I had a similar question (fonts instead of tabs) and ended up writing my own plugin for that selection. See accepted answer to this question – xubuntix Nov 18 '11 at 17:07
Thanks xubuntix. I've seen your answer, but it wasn't the same question. So I thought that changing another setting might be different. If it isn't I guess I'll start a little google code project which fulfils my demands with yours in one plugin. – Martin Thoma Nov 18 '11 at 17:27
I know its not the same, just wanted to make sure you saw that one. Having all this in one plugin might even be better... Good luck. – xubuntix Nov 18 '11 at 17:40

Not that I could see, I think you have to move up the IDE - editor to get to where you are wanting to go.

Geany might do this...

share|improve this answer

This can be done with the gedit plugin for modelines. Modelines are lines that you add to files for which you want certain settings. When you open files with modelines in editors that support them the editors will behave according to the modelines. So, you can think of modelines as per file settings of how for example indenting should work.

Here's how to do what you want in gedit:

  1. Make sure the plugin is loaded (Edit - Settings - Plugins - Modelines).
  2. Add modelines with the settings you want to your files.
  3. Gedit should act according to the modelines now.

Gedit support Emacs, Kate and Vim style modelines. Here's an example how you can do what you ask for with Emacs style modelines. Edit your java files such that they contain the following first line:

/* -*- mode: java; indent-tabs-mode: true; tab-width: 4 -*- */

class myfirstjavaprog
        public static void main(String args[])
           System.out.println("Hello World!");

This modeline will make the files containing it indent with tabs and and a width equal to 4 spaces. For your python files you can use the following first line:

/* -*- mode: python; indent-tabs-mode: nil; tab-width: 4 -*- */

print "Hello, World!"

This modeline will make files containing it indent with 4 spaces.

Obviously you could do something similar with Kate and Vim style modelines.

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.