Friday, January 9, 2009

Modelines

Vim allows you to insert modelines to specify options you'd like for a specific file. For example, you could have a perl script as follows:

#!/usr/bin/perl
# vim: set expandtab:
use strict;

This would tell Vim to expand tabs in the current file. See :help modeline for more info.

4 comments:

egypt said...

Keep in mind that vim has had a number of command execution vulnerabilities through modelines in the past. For safety's sake it might be a good idea to disable modelines altogether.

Anonymous said...

Off topic, but how do you list all of the recent commands made at the colon prompt? I know I've seen this before on this blog, but can't find it.

Thanks.

Casey

Travis Whitton said...

@Anonymous

Try :history

Travis

Anonymous said...

I suggest people check out the securemodelines plugin:

http://www.vim.org/scripts/script.php?script_id=1876