Questions tagged [modeline]

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

Filter by
Sorted by
Tagged with
10
votes
1answer
911 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 ...
5
votes
2answers
841 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 ...
5
votes
1answer
733 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 ...
4
votes
1answer
98 views

Is there a way to make some modeline that applies to all files in a directory, recursively?

I have a project consisting of files that Vim doesn't recognize by default, but has support for highlighting and indentation. I would like to have a vimrc file or a vimmodeline (or whatever similar) ...
3
votes
1answer
168 views

Having two modelines in one file, is that possible?

I have a Jinja2 template which I'd like Vim to syntax-highlight as a Jinja2 template, but the file - once rendered - will be an Nginx configuration file. Is there some way of getting Vim to use ...
3
votes
1answer
127 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
84 views

Mode line not working even if everything seems correct

I'm editing a file with the following pattern: # stock comment # stock comment # stock comment # stock comment # stock comment conf conf conf conf very_long_conf_line_xxxxxx (600+ chars) It's the ...
3
votes
2answers
671 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 ...
3
votes
1answer
709 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={{{,}}...
2
votes
1answer
129 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")...
1
vote
1answer
119 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 ...
1
vote
1answer
188 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 (...
1
vote
1answer
30 views

Is there any way to prevent modelines getting reapplied when files are saved / written?

For some Markdown documents, I like them to open with some sections initially folded (I use the plugin vim-markdown-folding). I've tried setting a modeline that looks like this: <!-- vi: set ...
1
vote
1answer
40 views

Vim's “path” variable isn't changing or updating with modeline setting (finding header file in different directory)

I'm trying to do something relatively simple: Editing a file in src and pointing Vim to the header file located in include. My .vimrc file has set modeline on, and the first line in my file is: // vim:...
1
vote
1answer
321 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
135 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 ...
0
votes
1answer
30 views

modelines not executed when opening new file in new tab

I'm often switching between files with a unix encoding and those with a dos encoding. I find that when I start with a unix encoded file, and then open a dos encoded file, vim attempts to use the ...