sponsor Vim development Vim logo Vim Book Ad

basic Tip #562: modeline sets vimrc options on a per file basis

 tip karma   Rating 7/6, Viewed by 1275 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   September 22, 2003 13:24      complexity:   basic
author:   Duane Smeckert      as of Vim:   5.7

Sometimes I want vi to treat a file different than the .vimrc file.
For example, I have a file that has fixed length text records,
tabs in this file would mess it up.
Setting the option expandtab will force tabs to be converted to spaces.

Near the top of the file I put a line that says:
# vim: set expandtab:

When I open the file after that it will replace ^I (tab characters) with the correct number of spaces.

 rate this tip  Life Changing Helpful Unfulfilling 

<< Context Sensitive h and l | useful Occurences under cursor and with prompt >>

Additional Notes

Anonymous, September 23, 2003 12:00
To read more about modelines, type:

    :help auto-setting
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo