editing files with VI and enforcing certain editor settings

You do know, that you can request VI (or VIM)  to make using the tab key equivalent to going e.g. 4 positions to the right (“:set tabstop=4“). But what if your colleague opens that file and has a global setting like “:set tabstop=8“?
As long as you don’t “globally” agree on this, it will at least help to add a setting with a “file-wide” scope. VI’s feature supporting such options is called modeline. There are 2 related settings, that make the use of that feature possible resp. impossible: “[no]modeline“, and “modelines=n“. For further reading do a “:help modeline” in VIM! (I guess, there are not that many original UCB VI-s around nowadays any more) That shows you samples and the exact syntax for how to add modelines.
I saw Jürgen Gulbins using this feature like 25 years ago, found it useful then, but never applied it myself in the meantime. But now in my current project with mixed VIM and Eclipse usage it seems to make very good sense, but I wasn’t able to recall the details. The article, that my Google enquiry pointed me to, was posted in December 2005 on the linux-il list: “vim inline :set“. Thanks to Meir Kriheli for answering the question there!


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.