4 ms·
I know this isn't quite what the article was about, but when he said "modelines" I thought of the lines you can place in a comment in a file to set editor optio
by Periodic 17y ago
I know this isn't quite what the article was about, but when he said "modelines" I thought of the lines you can place in a comment in a file to set editor options. For example, http://vim.wikia.com/wiki/Modeline_magic http://vim.wikia.com/wiki/Modeline_magic
It's great for making things consistent within a file when the editors people are using might not be consistent in their configuration. For example, I might be collaborating with one person who uses tabs with a shift width of 8, while in my own writing I may prefer to use 4 spaces.
So I can add:
/* vim: set noexpandtab:sw=8:ts=8 */
and suddenly vim will realize that it should treat an input of <tab> as a tab character and render them as 8 characters.
Alternately, if I were writing a document where I wanted all lines to be automatically wrapped to be within 80 characters but I usually let them continue indefinitely, I could add
/* vim: set wrap:tw=80 */
and I quickly have a per-file way of setting my editor's configuration.
- sid0 17y agoYeah, emacs has them too. Interestingly, I've noticed that Komodo supports emacs modelines, but vim doesn't.
- aerique 17y agoEmacs ought to understand Vim modelines. That would be very Emacs.
- jrockway 17y agoHow do you map vim to emacs? Emacs has much richer (for example) indentation properties; so there is not enough information for it to do the right thing. For simple things, like tab width, it could be made compatible, however. Personally, I prefer a human-readable set of guidelines, then I just configure emacs (via eproject) to set things up correctly for each project. Not as easy, I guess, but then new files I create for the project have the right settings by default.
- aeroevan 17y agoSame here. I was really hoping that this was a translation between vim and emacs modelines. That would actually be useful.
- shabble 17y agoThe equivalent for Emacs (sometimes known as the "Hey, Emacs!" line, is documented at http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables http://www.gnu.org/software/emacs/manual/html_node/emacs/Spe... There's also ways to set directory tree specific variables as well, so you can override the defaults for all files in a particular project. Very handy.