Daniel Nogradi wrote:
Hi vimmers,

I guess it's a simple thing but couldn't find a definite answer yet.
Is there a way to make commands such as

syn off
set foldmethod=expr

local in a sense that they should only effect the window in which they
are issued? I sometimes have several files open each in its own
splitted window and these commands seem to effect all. I use vim 6 in
an xterm.

Any ideas?


":syn off" is global; to turn off syntax highlighting locally you can use ":setlocal syntax=" (without the quotes), thus clearing 'syntax' buffer-locally.

'foldmethod' is local to window, meaning that each window has its local value, and there is also a global default applying to new empty files and to files where neither a filetype-plugin nor a modeline sets a local value. To set 'foldmethod' for one window only, use

        :setlocal foldmethod=expr
        :setlocal foldexpr=MyFoldExpr()

or something like that. (If you use a function, it's better to define it first.)

See ":help local-options" and read down several screens (123 lines in my version of the helpfile), until and including the "global-local" section.

To set local options the same way for one particular file every time you open it, you can use a |modeline|. Modelines must appear near the top or bottom of the file in question; for instance, the last line of every Vim helpfile is a modeline.


Best regards,
Tony.

Reply via email to