18

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?

2 Answers 2

14
+50

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 test.py. 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. :)

4
  • Could you please include an example to show how it works in gedit?
    – N.N.
    Sep 11, 2011 at 13:23
  • I have added a vim-style example modeline.
    – j1mc
    Sep 11, 2011 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, 2011 at 11:38
  • Here's another example of modelines, emacs style, that works with gedit: askubuntu.com/questions/80527/…
    – N.N.
    Nov 19, 2011 at 14:03
5

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).

3
  • 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, 2011 at 21:59
  • 2
    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. Aug 22, 2011 at 22:48
  • Could you please develop that and add it to your answer?
    – N.N.
    Aug 23, 2011 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .