Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Vim's feature name for this: # vim:sw=4:ts=4:et:

Tags:

vim

Even after 20 years with Vim, I keep forgetting name for the Vim feature where the editor picks up config statements from a comment at the beginning (or I think end) of a file:

# vim:sw=4:ts=4:et:

Thanks for a reminder!

like image 442
lzap Avatar asked Aug 19 '11 09:08

lzap


People also ask

What is Modeline in Vim?

modelines allow you to set variables specific to a file. By default, the first and last five lines are read by vim for variable settings. For example, if you put the following in the last line of a C program, you would get a textwidth of 60 chars when editing that file: /* vim: tw=60 ts=2: */

How do I find tabs in vim?

To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs.

What can you do with vim?

You can use it to quickly lookup commands, syntax, and more -- all without leaving the editor. You can even edit your file while referring to the documentation all on the same screen. The documentation that comes with Vim is very well written and easy to use.


1 Answers

It's called modeline

:he modeline

If you start editing a new file, and the 'modeline' option is on, a number of lines at the beginning and end of the file are checked for modelines. There are two forms of modelines.

  The first form:   [text]{white}{vi:|vim:|ex:}[white]{options}

 [text]         any text or empty
 {white}        at least one blank character (<Space> or <Tab>)
 {vi:|vim:|ex:} the string "vi:", "vim:" or "ex:"
 [white]        optional white space
 {options}      a list of option settings, separated with white space or ':',
                where each part between ':' is the argument for a ":set"
                command (can be empty)

Add this to $MYVIMRC:

setglobal modeline
like image 188
sehe Avatar answered Oct 18 '22 19:10

sehe