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

Howto NOT auto insert tabs ?

Expand Messages
  • Luc Martin
    Hi All, Please is there any single parameter to pass to vim/gvim for do not do auto inserting tabs (ie : gvim -classical ?) That makes vi less usable,
    Message 1 of 8 , Apr 3, 2001
    • 0 Attachment
      Hi All,

      Please is there any single parameter to pass to vim/gvim
      for do not do auto inserting tabs (ie : gvim -classical ?)
      That makes vi less usable, specially in copy-paste operations.

      Vim 5.5 Linux Mandrake 7.1

      TIA

      Luc
    • Zdenek Sekera
      Message 2 of 8 , Apr 3, 2001
      • 0 Attachment
        Luc Martin wrote:
        >
        > Hi All,
        >
        > Please is there any single parameter to pass to vim/gvim
        > for do not do auto inserting tabs (ie : gvim -classical ?)

        :set expandtab

        ---Zdenek
      • Fabien Penso
        ... Is there a way to tell vim not to put tabs but spaces for .php files, but only in comments. We use C style comments in php like: /* * Well nice function !
        Message 3 of 8 , Apr 3, 2001
        • 0 Attachment
          Zdenek Sekera <zs@...> a écrit:

          > > Please is there any single parameter to pass to vim/gvim
          > > for do not do auto inserting tabs (ie : gvim -classical ?)
          >
          > :set expandtab

          Is there a way to tell vim not to put tabs but spaces for .php files,
          but only in comments.
          We use C style comments in php like:

          /*
          * Well nice function !
          * Let's describe it here:
          *<tab><tab>This functions does ...
          */


          What I'd like vim to do, is to put space instead of tab when I hit <tab>
          in comments, as shown here, but put tabs inside the code. Is that
          possible ?

          Thanks.
        • Zdenek Sekera
          ... Well, if pasting and autoindent is the issue, better solution is
          Message 4 of 8 , Apr 3, 2001
          • 0 Attachment
            Mark Brophy wrote:
            >
            > Zdenek Sekera wrote:
            ...
            > > > Please is there any single parameter to pass to vim/gvim
            > > > for do not do auto inserting tabs (ie : gvim -classical ?)
            > >
            > > :set expandtab
            > >
            >
            > Actually, I think he means autoindent. I know I get annoyed
            > when pasting a lot of text into vim and everyline appears
            > indented from the previous.
            >
            > :set noai
            >

            Well, if pasting and autoindent is the issue, better solution is
            :set paste and then simply paste!

            ---Zdenek
          • Mark Brophy
            ... Actually, I think he means autoindent. I know I get annoyed when pasting a lot of text into vim and everyline appears indented from the previous. ... will
            Message 5 of 8 , Apr 3, 2001
            • 0 Attachment
              Zdenek Sekera wrote:
              >
              > Luc Martin wrote:
              > >
              > > Hi All,
              > >
              > > Please is there any single parameter to pass to vim/gvim
              > > for do not do auto inserting tabs (ie : gvim -classical ?)
              >
              > :set expandtab
              >

              Actually, I think he means autoindent. I know I get annoyed
              when pasting a lot of text into vim and everyline appears
              indented from the previous.

              :set noai

              will stop it.

              I think the problem is that when cutting/pasting it's the
              same as just typing in the text that has been selected,
              including the tabs, but vim inserts tabs at each line,
              to get up to the level of the previous tab, the result being
              that after a single tab, every line afterwards will end up
              with one more indentation than tbe previous.
              If you're using gvim, you can paste without being in insert
              mode, although I don't know if this will work with normal vim.

              Mark Brophy.
            • Benji Fisher
              Fabien Penso wrote: [snip] ... Vim does not have context-sensitive mappings, but you can do ... if getline( . ) =~ ^ s*/ = * return else return t
              Message 6 of 8 , Apr 3, 2001
              • 0 Attachment
                Fabien Penso wrote:
                [snip]

                >
                > Is there a way to tell vim not to put tabs but spaces for .php files,
                > but only in comments.
                > We use C style comments in php like:
                >
                > /*
                > * Well nice function !
                > * Let's describe it here:
                > *<tab><tab>This functions does ...
                > */
                >
                >
                > What I'd like vim to do, is to put space instead of tab when I hit <tab>
                > in comments, as shown here, but put tabs inside the code. Is that
                > possible ?

                Vim does not have context-sensitive mappings, but you can do
                something like this (untested):

                :imap <Tab> <C-R>=PhpTab()

                :fun! PhpTab()
                if getline(".") =~ '^\s*/\=\*'
                return " "
                else
                return "\t"
                endif
                endfun

                Variants: instead of testing whether the line matches a regexp, you could use

                if synIDattr(synID(line('.'),col('.'),1),'name') =~? "comment"

                (see the example under :help synID()). Instead of returning spaces or a
                tab, depending on the result of the test, you could try setting or
                unsetting the 'expandtab' option.

                HTH
                --Benji Fisher
              • Neil Bird
                ... Or use (IIRC) [p instead of p to paste ... I think that does it. Or something similar :-) -- =====================- http://www.thalesgroup.com/
                Message 7 of 8 , Apr 4, 2001
                • 0 Attachment
                  Zdenek Sekera wrote:
                  > Well, if pasting and autoindent is the issue, better solution is
                  > :set paste and then simply paste!

                  Or use (IIRC) '[p' instead of 'p' to paste ... I think that does it. Or
                  something similar :-)

                  --
                  =====================- http://www.thalesgroup.com/ -=====================
                  Neil Bird Principal Engineer |
                  work - mailto:neil.bird@... | $> cd /pub
                  personal - mailto:neil@... | $> more beer
                • Luc Hermitte
                  Hi, ... That s very interresting. But I got a little problem when I try to extend this function : fun! Foo(key, seq) if
                  Message 8 of 8 , Apr 4, 2001
                  • 0 Attachment
                    Hi,

                    On Tue, Apr 03, 2001 at 01:28:44PM -0400, Benji Fisher <benji@...> wrote:
                    > :imap <Tab> <C-R>=PhpTab()
                    > :fun! PhpTab()
                    > if synIDattr(synID(line('.'),col('.'),1),'name') =~? "comment"
                    > return " "
                    > else
                    > return "\t"
                    > endif
                    > endfun
                    >

                    That's very interresting. But I got a little problem when I try to
                    extend this function :

                    fun! Foo(key, seq)
                    if synIDattr(synID(line('.'),col('.'),1),'name') =~? "comment"
                    return a:key
                    else
                    return a:seq
                    endif
                    endfun

                    My aim is to expand <M-i> in "endif<esc>Oif" in normal mode and in "é"
                    within comments -- macro for editing VIM macro files.

                    So, I define
                    imap <M-i> <C-R>=Foo('<M-i>', "endif\<esc>Oif")<CR>
                    which does not work while
                    let trick = "endif\<esc>Oif"
                    imap <M-i> <C-R>=Foo('<M-i>', trick)<CR>
                    works fine.

                    Does anybody knows which characters I should escape in order to define
                    the map without any suppl. variable ?

                    I've tried "endif\<esc\>Oif", and other things like that, but I didn't
                    get the right one.

                    Thanks in advance.

                    Luc Hermitte
                  Your message has been successfully submitted and would be delivered to recipients shortly.