Can I change gEdit editor preferences according to the identified programming language?
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?
Solution 1:
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...
http://www.geany.org/Main/About
Solution 2:
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:
- Make sure the plugin is loaded (Edit - Settings - Plugins - Modelines).
- Add modelines with the settings you want to your files.
- 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.