Question

I have .zsh-theme files (from oh-my-zsh), but they are not syntax highlighted. I was able to get this done pretty easily with

autocmd BufEnter *.zsh-theme set filetype=sh

However, before I did that I tried adding a vim meta comment for a specific file

#vim: set filetype=sh

The addition of the # apparently makes vim detect the file as a conf file, but it seems that this command is ignored (i.e. it is not detected as a sh file in spite of the comment). Is there any reason this may be happening?

Was it helpful?

Solution

Get rid of the word set (and add a space after the comment symbol)

# vim: filetype=sh

This fits with the first form of modelines

There are two forms of modelines.  The first form:
        [text]{white}{vi:|vim:|ex:}[white]{options}

[text]                  any text or empty
{white}                 at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}          the string "vi:", "vim:" or "ex:"
[white]                 optional white space
{options}               a list of option settings, separated with white space
                        or ':', where each part between ':' is the argument
                        for a ":set" command (can be empty)

OTHER TIPS

The syntax for this type of modeline is:

[text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]

That is, try adding a space before vim:, and a trailing colon:

# vim: set filetype=sh:

You can find everything about modelines in

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top