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

Re: what does "vim:et:ts..." mean in vi?

Expand Messages
  • Tony Mechelynck
    ... Short answer: After vim: each colon-separated part is the argument of a ... Long answer: See (in Vim) ... …and read attentively, it is said that some
    Message 1 of 5 , Jan 5, 2013
      On 06/01/13 02:33, skyworld wrote:
      > Hi,
      >
      > I'm reading someone's code and at the end of the file I found some
      > code like this:
      >
      >
      > #
      > ###########################################################################­
      > #
      > #{{{ * Editor configuration
      > #
      > ###########################################################################­
      > #
      > # Local Variables:
      > # mode: python
      > # mode: outline-minor
      > # outline-regexp: " *#{{{ [#*]+"
      > # indent-tabs-mode: nil
      > # End:
      > # vim:et:sw=4:ts=4:ft=python:
      >
      >
      > I'm interested those "vim:et:sw...." because I'm a user of vi, but I
      > don't know what these "comments" means and I guess they have some
      > special usage. Can anybody help me? thanks.
      >

      Short answer: After vim: each colon-separated part is the argument of a
      :setlocal command.

      Long answer: See (in Vim)
      :help modeline
      :help 'modeline'
      :help 'modelines'

      …and read attentively, it is said that "some" forms of modelines are
      compatible with "some" versions of (legacy) vi. Or maybe your vi version
      has help about them?


      Best regards,
      Tony.
      --
      In India, "cold weather" is merely a conventional phrase and has come
      into use through the necessity of having some way to distinguish
      between weather which will melt a brass door-knob and weather which
      will only make it mushy.
      -- Mark Twain

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Tony Mechelynck
      ... The comment should be put within modelines lines (usually 5 lines) of the beginning *or* end of the file, your choice. It will only work if modeline
      Message 2 of 5 , Jan 5, 2013
        On 06/01/13 03:25, skyworld wrote:
        > Hi Tim & Tony,
        >
        > thanks for your kind reply. After reading the help, I still have a
        > question on this:
        >
        > the help has two examples on this:
        > a) Example:
        > vi:noai:sw=3 ts=6
        > b) Example:
        > /* vim: set ai tw=75: */
        > and in my code:
        > c) # vim:et:sw=4:ts=4:ft=python:
        >
        > Since these three examples has different formats at beginning (i.e, /*
        > or # or ""), I guess the vim modeline settings should be "put" after
        > the comments of the line, and this comment maybe different, e.g, if
        > you are using C, it should be put behind /*; and if you are using
        > shell/perl/python, it should be put behind "#". And this comment
        > should be put at the end of the file. Do I understand this correct?
        > thanks.
        >
        >
        > Skyworld

        The comment should be put within 'modelines' lines (usually 5 lines) of
        the beginning *or* end of the file, your choice. It will only work if
        'modeline' (in the singular) is on, which is the default provided that
        you're running Vim in 'nocompatible' mode and not in the root (i.e.
        sysadmin) login account.

        When using C with /* and */, you should use the second form (with "set")
        because the other one goes on till the end of the line. Similarly for
        HTML or XML with <!-- and -->. In the case of HTML you may prefer to put
        the modeline near the top of the file, immediately after the <head>
        opening tag. OTOH for C++ or javascript or CSS you can use a // comment
        and that needs no closing boundary other than the end of the line, so in
        that case a modeline of the first form (with colons and no "set") is
        acceptable.

        And yes, how the comment is written depends on the programming language:
        # in (for instance) a shell script, a double-quote character in a Vim
        script, and I gave other examples in the above paragraph.


        Best regards,
        Tony.
        --
        If little else, the brain is an educational toy.
        -- Tom Robbins

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • skyworld
        thanks very much. skyworld On Jan 6, 11:29 am, Tony Mechelynck ... -- You received this message from the vim_use maillist. Do
        Message 3 of 5 , Jan 5, 2013
          thanks very much.


          skyworld

          On Jan 6, 11:29 am, Tony Mechelynck <antoine.mechely...@...>
          wrote:
          > On 06/01/13 03:25, skyworld wrote:
          >
          >
          >
          >
          >
          > > Hi Tim & Tony,
          >
          > > thanks for your kind reply. After reading the help, I still have a
          > > question on this:
          >
          > > the help has two examples on this:
          > > a) Example:
          > >     vi:noai:sw=3 ts=6
          > > b) Example:
          > >     /* vim: set ai tw=75: */
          > > and in my code:
          > > c) # vim:et:sw=4:ts=4:ft=python:
          >
          > > Since these three examples has different formats at beginning (i.e, /*
          > > or # or ""), I guess the vim modeline settings should be "put" after
          > > the comments of the line, and this comment maybe different, e.g, if
          > > you are using C, it should be put behind /*; and if you are using
          > > shell/perl/python, it should be put behind "#". And this comment
          > > should be put at the end of the file. Do I understand this correct?
          > > thanks.
          >
          > > Skyworld
          >
          > The comment should be put within 'modelines' lines (usually 5 lines) of
          > the beginning *or* end of the file, your choice. It will only work if
          > 'modeline' (in the singular) is on, which is the default provided that
          > you're running Vim in 'nocompatible' mode and not in the root (i.e.
          > sysadmin) login account.
          >
          > When using C with /* and */, you should use the second form (with "set")
          > because the other one goes on till the end of the line. Similarly for
          > HTML or XML with <!-- and -->. In the case of HTML you may prefer to put
          > the modeline near the top of the file, immediately after the <head>
          > opening tag. OTOH for C++ or javascript or CSS you can use a // comment
          > and that needs no closing boundary other than the end of the line, so in
          > that case a modeline of the first form (with colons and no "set") is
          > acceptable.
          >
          > And yes, how the comment is written depends on the programming language:
          > # in (for instance) a shell script, a double-quote character in a Vim
          > script, and I gave other examples in the above paragraph.
          >
          > Best regards,
          > Tony.
          > --
          > If little else, the brain is an educational toy.
          >                 -- Tom Robbins- Hide quoted text -
          >
          > - Show quoted text -

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.