Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [modeline]

An annotation at the beginning or end of a text document to configure the editor for that document

0
votes
0answers
32 views

Compabitibility between vim and emacs style modelines

I'm a long-time vim user. Today I learned something new: modeline(s). For the many years, 15+, that I've used vim, I've handled this through autocommands for specific file types. Today, while ...
1
vote
1answer
69 views

Why is modeline off for root?

I just discovered that vim defaults modeline to off when executed as root. What is the reason for this?
1
vote
1answer
52 views

Local persistent undo file modeline

I have undodir=~/.vim/undodir such that persistent-undo history files don't clutter my source code directories. However, for one particular source file, I'd like to have its persistent-undo history ...
0
votes
0answers
151 views

Set syntax highlighting for a range of lines

I am generating a Makefile using a Zsh script. But this issue might be encountered in every language. I store a part of the Makefile in a variable using an here-document: makefile=$(<<- ...
1
vote
1answer
75 views

What are the compatibility differences between the two modelines?

:h modeline says the following: There are two forms of modelines. The first form: [text]{white}{vi:|vim:|ex:}[white]{options} (...) vi:noai:sw=3 ts=6 ~ vim: tw=77 ~ The second form (...
2
votes
1answer
76 views

How to unfold a fold the cursor is in using modeline?

I've got automatic folding enabled in my file with the following modeline: " vim:foldmethod=marker:foldlevel=0 I also have an autocmd like this to place the cursor where I left it: if has("autocmd")...
4
votes
1answer
442 views

How to set a key mapping in the modeline?

I have a text file where I keep my personal notes. They're structured in a certain way, so I can operate on those notes with vim commands. I would like to map a keyboard shortcut to a specific set of ...
3
votes
1answer
97 views

How to apply a modeline added to an unnamed buffer?

I have the following workflow: Create a new unnamed buffer with :enew Use a snippet to add a modeline to it. E.g. vim:tw=80:ft=text:spell Once I've done that the modeline isn't applied and I can't ...
3
votes
1answer
351 views

Modeline folding not working on help file

I'm writing a helpfile for a plugin, i.e. a foo.txt file that goes in the plugin's doc/ directory. At the bottom of that file I placed the following modeline: vim: tw=70 ft=help fdm=marker fmr={{{,}}...
1
vote
1answer
101 views

Vimdiff does not read modeline

I have a modeline in a file # vim: set filetype=sshconfig : This sets filetype correctly in vim, but when opening the file in vimdiff, the filetype is set to conf. How can I tell vimdiff to read the ...
10
votes
1answer
720 views

Is it possible to create custom “set” commands in my rc file and call them from a modeline?

I recently asked a question in which I learned that it is not possible to pass anything except parameters to :set in vim modelines. I understand the security concerns, but I'm wondering if there isn't ...
3
votes
2answers
611 views

Is it possible to include coding style vim modelines e.g. psr-2 or drupal? [duplicate]

In vim you can include modelines in comments at the start/end of a file, like // vim:sw=4 ts=4 et I regularly work with PHP and try to stick to PSR-2 but Drupal (of course *rolls eyes*) has to be ...
5
votes
2answers
586 views

Is there a way to set an abbreviation in a modeline so it is always available local to one file buffer?

I have a handful of files (LaTeX documents) that have one specific proper name that is really obnoxious to type out but used frequently. I've eased the pain of this with an abbreviation like so: iab ...