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

Re: ^T/^D in insert mode - functionality question

Expand Messages
  • GI
    ... Doesn t vim already have an option for this? I have sw=4, and when I press at the begining of the line, I get sw number of spaces. 8 consecutive
    Message 1 of 4 , Nov 16, 2004
    • 0 Attachment
      On Tue, Nov 16, 2004 at 10:35:05AM -0800, Chris Downey wrote:

      >
      > Several people in the office where I work have been used to setting ts=4
      > so as to get a more reasonable level of indentation in their code. I
      > find this objectionable, because most of the utilities on *nix systems
      > assume that tabs are every 8 spaces, and hence the code layout is messed
      > up when, say, viewing a file with "more".
      >
      > I have long helf the belief that a better solution is to set sw=4 and
      > just to use ^T/^D in insert mode to handle indentation. Many people are
      > resistant to this solution because they are so used to just hitting tab,
      > and the solution I have always given them is to simply map! tab to ^T.
      > This works well in the original vi, and I've been advising people thusly
      > for several decades.
      >
      > However: it's a problem in vim, because ^T and ^D change the
      > indentation of the current line *wherever you are* in that line. In
      > other words, you can be halfway along the line and hit ^T and the
      > whole line gets indented an extra shiftwidth spaces. This causes much
      > consternation when the above-mentioned tab map is applied, since
      > hitting tab anywhere in a line causes the indentation to change.

      Doesn't vim already have an option for this? I have sw=4, and when I
      press <Tab> at the begining of the line, I get sw number of spaces. 8
      consecutive spaces get mapped to a tab too ...

      Hmm... grep tab .vimrc | help --

      :help 'smarttab'

      'smarttab' 'sta' boolean (default off)
      global
      {not in Vi}
      When on, a <Tab> in front of a line inserts blanks according to
      'shiftwidth'. 'tabstop' is used in other places. A <BS> will delete
      a 'shiftwidth' worth of space at the start of the line.
      When off a <Tab> always inserts blanks according to 'tabstop'.
      'shiftwidth' is only used for shifting text left or right
      |shift-left-right|.
      What gets inserted (a Tab or spaces) depends on the 'expandtab'
      option. Also see |ins-expandtab|. When 'expandtab' is not set, the
      number of spaces minimized by using <Tab>s.
      NOTE: This option is reset when 'compatible' is set.

      GI

      --
      'Hozone' -- The area over by 6th street.
    Your message has been successfully submitted and would be delivered to recipients shortly.