Loading ...
Sorry, an error occurred while loading the content.

66323Re: Any way to get vim recognize emacs modeline?

Expand Messages
  • Charles E. Campbell, Jr.
    Mar 2, 2006
    • 0 Attachment
      panshizhu@... wrote:

      >such as the following:
      >
      >// -*- C++ -*-
      >
      >I don't use emacs, but many source files have this, since the standard C++
      >header does not had any "extension" in the filename, it is impossible for
      >Vim getting it's filetype right.
      >
      >Can Vim recognize the standard C++ header files "by default"?
      >
      >

      You can always write your own modeline handler. General procedure:
      (untested)

      a) au BufRead,BufNewFile * call MyOwnModelineHandler()
      goes into your <.vimrc>

      b) write MyOwnModelineHandler(). Do something like

      fun! MyOwnModelineHandler()
      let mp1= &modelines + 1
      let modeline= search('^\%<'.mpl.'l//-\*- ','W')
      if !modeline
      let mpend= line("$") - &modelines - 1
      let modeline= search('^\%>'.mpend.'l//-\*-','W')
      endif
      if modeline
      ---interpret and do whatever---
      endif
      endfun

      Place the function in your .vimrc or in your .vim/plugin directory.

      Enjoy!
      Chip Campbell
    • Show all 7 messages in this topic