Vim In-File Commands?

Vim modeline syntax (see :help modeline ) is not intended to specify commands to execute during file opening. That is exactly what autocommands is for (see :help autocommand ). What you are trying to do should be an autocommand similar the following.

Up vote 2 down vote favorite share g+ share fb share tw.

I'm after a means by which I can add additional commands to a text file via vim. For example, just as you can do something like this: # vim:syntax=foo I'd like to do something like: # vim:option call matchadd('Special', '\(REQUIRED\|OPTIONAL\)') Any ideas? I know I can write a syntax file, but this is not what I'm after for now.

Vim link|improve this question asked Jun 16 '11 at 0:57Cyrus5281612 67% accept rate.

Vim modeline syntax (see :help modeline) is not intended to specify commands to execute during file opening. That is exactly what autocommands is for (see :help autocommand). What you are trying to do should be an autocommand similar the following.

Autocmd FileType foo call matchadd('Special', '\(REQUIRED\|OPTIONAL\)') or autocmd BufReadPost *. Foo call matchadd('Special', '\(REQUIRED\|OPTIONAL\)') (Here instead of *. Foo you can use any pattern that matches path or filename (or both) of the target file.

) If the configuration you are setting up is local to some files or a project, and you don't want to pollute your . Vimrc with those autocmds, use localvimrc plugin. It allows you to have a "local" .

Vimrc file next to your target file or project folder. Script stored in that . Lvimrc is executed when you open files in the same directory where the "local" .

Vimrc is, or in its subdirectories. Autocommands shown above (or any other configurations) can be stored in a . Lvimrc file local the project.

For details about localvimrc configuration see the homepage of the plugin.

So it's not possible, but that's okay, I've just now added a . Vim/ syntax file; and your comments are nevertheless very useful - thank you :) – Cyrus Jun 17 '11 at 0:29 1 +1 from that localvimrc tip! – progo Jun 19 '11 at 14:58.

This isn't an answer to your question, but I have also searched for Truth, and this question here is the closest one to it: Vim: How to execute selected text as vim commands It isn't automatic, but potentially only one keypress away it's close enough. :).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions