Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed vim settings in file

Tags:

vim

In some files I can see a commented line, usually the last, with vim settings. Does vim read these settings? If it does, are any limitations of what kind of settings man can put there?

like image 628
kfl62 Avatar asked Oct 18 '10 10:10

kfl62


People also ask

Where do I put Vim config?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

What is a vimrc file?

Settings file used by Vim, a text editing program often used by source code developers and system administrators; saves the default settings for the editor when it is opened; allows users to customize options for the editor. VIMRC files are saved in a plain text format.

What is Vim Modeline?

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: */


1 Answers

They're called modelines and while I'm not sure the extent you can go with them, here's a link to the vimtips wiki with some examples:

http://vim.wikia.com/wiki/Modeline_magic

help modeline 

from within vim to check out the official docs.

like image 101
Rick Avatar answered Oct 02 '22 17:10

Rick