Vim Modelines

Temporarily setting Vim options like nowrap and guioptions+=b can be helpful for log files. But it is inconvenient to either set permanent options in vimrc or to type these options each time.

Vim modelines allow you to set Vim options per file.

The trade-off is that modelines appear directly in the file. So, you might have to work with a copy of a file if editing is not allowed.

Just add the modeline directly to the top or bottom of the file. Here is an example from my notes. The next time I open this file, the long lines will scroll off the edge and if I am using gVim then I will get a scroll bar at the bottom of the window.

vim:nowrap guioptions+=b



Created: Friday, May 6, 2022

Updated: Friday, May 6, 2022