Vim Modelines

Everyone seems to have their own favorite editing preferences regarding things like:

  1. Should tabs be converted to spaces?
  2. How many spaces should be used if I hit the tab key?
  3. How many spaces should be for an indentation?

And so on and so forth.

Most editors, including TKE, allow you to specify these various editing preferences to your individual liking, but how should these settings be handled if you are sharing a file with a wider audience? If everyone uses different values and makes edits to the file, the structure of the file is going to look really bad, making the code harder to read and understand.

In smaller circles, you could make a “rule” that everyone must never use tab characters, but this rule is hard to enforce, especially in a larger audience.

Fortunately, for most editors that support Vim, which includes TKE, there is the concept of the Vim modeline. This is a line towards the top or bottom of a file which tells the editor how to handle formatting for the given file. These formatting options are specific to the file and will not mess up your preference values.

To create a Vim modeline to your file, it is best to put it inside a comment block in either the first or second line of the file or at the very bottom of the file. TKE allows you to specify how many lines at the top or bottom of the file to look for a modeline.

The following graphic shows an example of what a modeline might look like:


This example modeline sets the file format (endline character) to use the unix format, sets the shiftwidth value to 4 spaces and forces the editing buffer to treat the file as Tcl syntax.

You can learn more about modelines in the official Vim documentation at

To see more information and download your copy of the TKE code editor, visit

Vim Modelines

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s