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

'autoindent', 'paste' and pasting indented text in Insert mode?

Expand Messages
  • Valery Kondakoff
    Hello, vim! When pasting some indented text in Insert mode it is pasted with weird additional indentation. For example, if I m pasting these three lines in
    Message 1 of 7 , Apr 2, 2003
    • 0 Attachment
      Hello, vim!

      When pasting some indented text in Insert mode it is pasted with weird
      additional indentation.

      For example, if I'm pasting these three lines in Insert mode:

      test
      test
      test

      They will be pasted like this:

      test
      test
      test

      As far as I understand, this happens because I enabled 'autoindent'
      option, and VIM thinks, that pasted text is entered manually. But
      after reading the description of a 'paste' option I found the
      following:

      -----
      Setting this option is useful when using Vim in a terminal, where Vim
      cannot distinguish between typed text and pasted text. In the GUI,
      Vim knows about pasting and will mostly do the right thing without 'paste'
      being set.
      -----

      So, as far as I understand, the VIM makes difference between typed and
      pasted text, because I'm using GUI version (GVim 6.1.423, WinXP Pro).

      What's the problem? Why GVim creates additional indentation, when
      pasting text in Insert mode?

      Thank you.

      --
      Best regards,
      Valery Kondakoff
      http://www.nbk.orc.ru (Ne Bey Kopytom)
      http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

      np: Pussyfoot - Sea Breeze #C - Chari Chari (Fish Smell Like Cat) [stopped]
    • Lukas Ruf
      ... HTH wbr, Lukas -- Lukas Ruf | Wanna know anything about raw | | IP? |
      Message 2 of 7 , Apr 2, 2003
      • 0 Attachment
        * Valery Kondakoff <strauss@...> [2003-04-02 16:37]:
        >
        > When pasting some indented text in Insert mode it is pasted with weird
        > additional indentation.
        >
        > For example, if I'm pasting these three lines in Insert mode:
        >
        > test
        > test
        > test
        >
        > They will be pasted like this:
        >
        > test
        > test
        > test
        >
        :help 'pastetoggle'

        HTH

        wbr,
        Lukas
        --
        Lukas Ruf | Wanna know anything about raw |
        <http://www.lpr.ch> | IP? <http://www.rawip.org> |
      • Valery Kondakoff
        Hello, Lukas! ... LR :help pastetoggle Thank you. After reading paste description, I was thinking, that it is not necessary to set paste or
        Message 3 of 7 , Apr 2, 2003
        • 0 Attachment
          Hello, Lukas!

          Wednesday, April 2, 2003, you wrote to me:

          >> When pasting some indented text in Insert mode it is pasted with weird
          >> additional indentation.
          >>
          LR> :help 'pastetoggle'

          Thank you. After reading 'paste' description, I was thinking, that it
          is not necessary to set 'paste' or 'pastetoggle', when using GUI...

          Here are the lines in question (from VIM help):

          -----
          Setting this option is useful when using Vim in a terminal, where Vim
          cannot distinguish between typed text and pasted text. In the GUI,
          Vim knows about pasting and will mostly do the right thing without 'paste'
          being set.
          -----

          Am I wrong? Do I still need to set 'paste/pastetoggle' even in GUI?

          Thank you once again.

          --
          Best regards,
          Valery Kondakoff
          http://www.nbk.orc.ru (Ne Bey Kopytom)
          http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

          PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

          np: Pussyfoot - Sea Breeze #C - Chari Chari (Fish Smell Like Cat) [stopped]
        • Piet Delport
          ... [...] ... No, you shouldn t need to. How exactly are you doing your pasting? -- Piet Delport Today s subliminal thought is:
          Message 4 of 7 , Apr 3, 2003
          • 0 Attachment
            On Wed, 02 Apr 2003 at 21:10:55 +0400, Valery Kondakoff wrote:
            >
            [...]
            >
            > After reading 'paste' description, I was thinking, that it
            > is not necessary to set 'paste' or 'pastetoggle', when using GUI...
            >
            > Here are the lines in question (from VIM help):
            >
            > -----
            > Setting this option is useful when using Vim in a terminal, where Vim
            > cannot distinguish between typed text and pasted text. In the GUI,
            > Vim knows about pasting and will mostly do the right thing without 'paste'
            > being set.
            > -----
            >
            > Am I wrong? Do I still need to set 'paste/pastetoggle' even in GUI?

            No, you shouldn't need to. How exactly are you doing your pasting?

            --
            Piet Delport
            Today's subliminal thought is:
          • Valery Kondakoff
            Hello, Piet! ... PD No, you shouldn t need to. How exactly are you doing your pasting? ... When pasting some indented text in Insert mode it is pasted with
            Message 5 of 7 , Apr 3, 2003
            • 0 Attachment
              Hello, Piet!

              Thursday, April 3, 2003, you wrote to me:

              >> Am I wrong? Do I still need to set 'paste/pastetoggle' even in GUI?

              PD> No, you shouldn't need to. How exactly are you doing your pasting?

              This is an example from my initial message:

              >8<======================<start>======================>8<
              When pasting some indented text in Insert mode it is pasted with weird
              additional indentation.

              For example, if I'm pasting these three lines in Insert mode:

              test
              test
              test

              They will be pasted like this:

              test
              test
              test
              >8<=======================<end>=======================>8<

              Just set the cursor on first 'test', press '<C-v>2jd' to select and cut
              the three lines. Then go to insert mode and paste the line back:
              'i<C-r><S-">'. The text is pasted with additional indentation on
              third line ('autoformat' is 'on').

              --
              Best regards,
              Valery Kondakoff
              http://www.nbk.orc.ru (Ne Bey Kopytom)
              http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

              PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

              np: The Police - Does Everyone Stare (Reggatta De Blanc) [stopped]
            • Bram Moolenaar
              ... You probably mean 2jd , otherwise you would cut only one column. ... See :help i_CTRL-R and :help i_CTRL-R_CTRL-O and notice the difference. --
              Message 6 of 7 , Apr 3, 2003
              • 0 Attachment
                Valery Kodakoff wrote:

                > Just set the cursor on first 'test', press '<C-v>2jd' to select and cut

                You probably mean "<S-v>2jd", otherwise you would cut only one column.

                > the three lines. Then go to insert mode and paste the line back:
                > 'i<C-r><S-">'. The text is pasted with additional indentation on
                > third line ('autoformat' is 'on').

                See ":help i_CTRL-R" and ":help i_CTRL-R_CTRL-O" and notice the
                difference.

                --
                ARTHUR: Well, I can't just call you `Man'.
                DENNIS: Well, you could say `Dennis'.
                ARTHUR: Well, I didn't know you were called `Dennis.'
                DENNIS: Well, you didn't bother to find out, did you?
                The Quest for the Holy Grail (Monty Python)

                /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
                \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
              • Valery Kondakoff
                Hello, Bram! ... BM You probably mean 2jd , otherwise you would cut only one column. Of course. Just a typo. ... BM See :help i_CTRL-R and :help
                Message 7 of 7 , Apr 3, 2003
                • 0 Attachment
                  Hello, Bram!

                  Thursday, April 3, 2003, you wrote to me:

                  >> Just set the cursor on first 'test', press '<C-v>2jd' to select and cut
                  BM> You probably mean "<S-v>2jd", otherwise you would cut only one column.

                  Of course. Just a typo.

                  >> the three lines. Then go to insert mode and paste the line back:
                  >> 'i<C-r><S-">'. The text is pasted with additional indentation on
                  >> third line ('autoformat' is 'on').

                  BM> See ":help i_CTRL-R" and ":help i_CTRL-R_CTRL-O" and notice the
                  BM> difference.

                  That's it!

                  <C-r>:
                  The text is inserted as if you typed it, but mappings and
                  abbreviations are not used. If you have options like
                  'textwidth', 'formatoptions', or 'autoindent' set, this will
                  influence what will be inserted. This is different from what
                  happens with the "p" command and pasting with the mouse.

                  <C-r> <C-o>:
                  Insert the contents of a register literally and don't
                  auto-indent.

                  Bram, thank you for pointing me to a right place in the documentation.
                  I'm trying to find an answers in the documentation before posting a
                  question to the list, but it's not always easy to find right place in
                  the docs! :)

                  The 'paste' case is closed! :)

                  --
                  Best regards,
                  Valery Kondakoff
                  http://www.nbk.orc.ru (Ne Bey Kopytom)
                  http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

                  PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

                  np: The Police - It's Alright For You (Reggatta De Blanc)
                Your message has been successfully submitted and would be delivered to recipients shortly.