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

Re: mechnism for autoindent

Expand Messages
  • Thomas Adam
    ... I find that useful. -- Thomas Adam ===== The Linux Weekend Mechanic -- http://linuxgazette.net TAG Editor -- http://linuxgazette.net
    Message 1 of 5 , Jan 4, 2004
    • 0 Attachment
      --- Timothy Washington <timothyjwashington@...> wrote: >
      > Does anyone know the mechanism autoindent uses to place the correct
      > amount of indents after going to a new line? My vim is autoindenting
      > with 1 too may tabs on the next line and I'm trying to fix it. Thanks
      > in advance.

      :set sw=2

      I find that useful.

      -- Thomas Adam

      =====
      "The Linux Weekend Mechanic" -- http://linuxgazette.net
      "TAG Editor" -- http://linuxgazette.net

      "<shrug> We'll just save up your sins, Thomas, and punish
      you for all of them at once when you get better. The
      experience will probably kill you. :)"

      -- Benjamin A. Okopnik (Linux Gazette Technical Editor)

      ________________________________________________________________________
      Yahoo! Messenger - Communicate instantly..."Ping"
      your friends today! Download Messenger Now
      http://uk.messenger.yahoo.com/download/index.html
    • Benji Fisher
      ... Please give a specific example of what happens. Be explicit enough that others can try to reproduce it, and say what you want to happen. If you would
      Message 2 of 5 , Jan 4, 2004
      • 0 Attachment
        On Sun, Jan 04, 2004 at 10:52:17PM -0500, Timothy Washington wrote:
        >
        > Does anyone know the mechanism autoindent uses to place the correct
        > amount of indents after going to a new line? My vim is autoindenting
        > with 1 too may tabs on the next line and I'm trying to fix it. Thanks
        > in advance.

        Please give a specific example of what happens. Be explicit enough
        that others can try to reproduce it, and say what you want to happen.

        If you would prefer to read a detailed explanation of how vim
        indents, start with

        :help usr_30.txt

        in the users' manual.

        HTH --Benji Fisher
      • Antoine J. Mechelynck
        ... IIUC, 1) autoindent does not work if you have :filetype indent on (and the indent file for the current filetype has set indentexpr ), or if paste is
        Message 3 of 5 , Jan 4, 2004
        • 0 Attachment
          Timothy Washington <timothyjwashington@...> wrote:
          > Does anyone know the mechanism autoindent uses to place the correct
          > amount of indents after going to a new line? My vim is autoindenting
          > with 1 too may tabs on the next line and I'm trying to fix it. Thanks
          > in advance.
          >
          >
          >
          > Timothy Washington
          > timothyjwashington@...
          > 416.457.6599

          IIUC,

          1) 'autoindent' does not work if you have :filetype indent on (and the
          indent file for the current filetype has set 'indentexpr'), or if 'paste' is
          on, or if you have set 'intentexpr' to non-empty yourself.

          2) Otherwise, if you have set 'autointent', then:

          a) <Enter> in Insert or Replace mode copies the indent of the current line
          to the next one

          b) O or o in Normal mode copies the indent of the line where the cursor was
          to the new line above or below it.

          See
          :help autoindent
          :help indentexpr
          :help :filetype
          :help :filetype-indent-on
          :help :filetype-indent-off
          :help :filetype-overview
          :help o
          :help O

          HTH,
          Tony
        • Benji Fisher
          ... First, a little bit of list etiquette: please reply on the list, not just to one person. There are many friendly people on the list who would like to
          Message 4 of 5 , Jan 5, 2004
          • 0 Attachment
            On Mon, Jan 05, 2004 at 01:26:55AM -0500, Timothy Washington wrote:
            > On Sunday, January 4, 2004, at 11:37 PM, Benji Fisher wrote:
            > > On Sun, Jan 04, 2004 at 10:52:17PM -0500, Timothy Washington wrote:
            > >
            > > > Does anyone know the mechanism autoindent uses to place the
            > > > correct amount of indents after going to a new line? My vim is
            > > > autoindenting with 1 too may tabs on the next line and I'm trying
            > > > to fix it. Thanks in advance.
            > >
            > > Please give a specific example of what happens. Be explicit
            > > enough that others can try to reproduce it, and say what you want to
            > > happen.
            >
            > You're right. Sorry for the vagueness. I want to be able to control
            > the behaviour of "autoindent" in vim 6.1 on my Mac OS X.
            >
            >
            > WHAT HAPPENS:
            > I am editing an html file. After typing the first opening tag, I press
            > enter and go to the next line. The problem is that the amount of indent
            > tabs given is too much
            >
            > ex)
            > <head>
            > <title ... > // this should be flush with the line below
            > <link rel="stylesheet" href="2.css" type="text/css"/>
            > </head>
            >
            > WHAT I WANT TO HAPPEN
            > I want to tell vim to put <title /> 1 extra tab beyond <head/>.

            First, a little bit of list etiquette: please reply on the list,
            not just to one person. There are many friendly people on the list who
            would like to help, and they should be able to see this exchange. There
            may also be lurkers who have the same problem. Second, while I prefer
            adding responses at the bottom of the e-mail, which is the most common
            form here, I try not to be prescriptive about it. But please do not
            reply at the top on a thread where someone has already replied at the
            bottom, or vice-versa: that gets really hard to read.

            When I type in your example, I get

            ===
            <head>
            <title ...>
            <link href="2.css"/>
            </head>
            ===

            We seem to have different settings for the 'shiftwidth' option, but that
            does not bother me.

            Indentation is controlled by the script
            $VIMRUNTIME/indent/html.vim . If you get the current version of this
            script (or upgrade to vim 6.2) then we should get the same results,
            although that is still not what you want. You can modify this script to
            do what you want, or you can "turn it off" with

            :set indentexpr=

            For more details, see

            :help 30.3
            :help 30.4

            in the users' manual. You may also find Section 14 of the FAQ helpful:
            http://vimdoc.sf.net/cgi-bin/vimfaq2html3.pl?faq=1&cs=
            In particular, you can adjust the indent manually (with or without
            turning off the indent script) with <C-T> and <C-D>.

            HTH --Benji Fisher
          Your message has been successfully submitted and would be delivered to recipients shortly.