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

There is a gedit plugin called Modelines and the plugin is described as

Emacs, Kate and Vim-style modelines support for gedit.

What are modelines? And how do they work in gedit?

share|improve this question
up vote 11 down vote accepted

Modelines allow you to set preferences on a file-by-file basis, and allow you to mimic some of the preference-setting options of a few other popular editors (Vim, Emacs, and Kate).

For example, if you have your gedit preferences set to use 4 spaces per indentation, you can use modelines to override this and set only 2 spaces per indentation on that particular file.

Actually creating modelines in your documents is another matter, though. It can be rather complex (look at the documentation for the Kate modelines), and is generally suited to people who are intimately familiar with their editors of choice. This is why the gedit documentation links out to the various manuals for Vim, Emacs, and Kate, rather than describing their modelines in detail within the documentation.

Here is a sample vim-style modeline in a python file. Let's call it The line at the end turns on the modelines, sets the tab spaces at 24 spaces (clearly a bad python coding practice, but done just for effect here), and turns off the expanded tabs feature.

print "hello"
print "say what?"

# ex:set ts=24 noet:

Give it a try in gedit and let me know if it works for you. The vim modeline options are documented fairly well here. If you would like to wade through the Emacs documentation to find their modeline options, you are welcome to do so. :)

share|improve this answer
Could you please include an example to show how it works in gedit? – N.N. Sep 11 '11 at 13:23
I have added a vim-style example modeline. – j1mc Sep 11 '11 at 18:57
Appreciated. Is there any modeline options that are particularly useful or popular? It might make sense to include such in an answer. – N.N. Sep 12 '11 at 11:38
Here's another example of modelines, emacs style, that works with gedit:… – N.N. Nov 19 '11 at 14:03

Gedit modelines are described here.

In text file (in source code comments for example) you can add some configuration customization hints for the editor (like display tab as 4 spaces in this this file).

share|improve this answer
Now it's a better answer but it's not a good one. It's preferred that answers are written directly and not linked. – N.N. Aug 22 '11 at 21:59
It's described briefly in second paragraph: Modelines are "hints". The example of how they work in gedit is in second bracket of the answer. – Michał Šrajer Aug 22 '11 at 22:48
Could you please develop that and add it to your answer? – N.N. Aug 23 '11 at 9:42
+1 for citing the correct documentation. – ændrük Sep 15 '11 at 18:33

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.