indents when copying and pasting

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

indents when copying and pasting

luke-44
Hi Guys.

I really like this list.
Everyone is so helpful.
That's not just a suck-up (-:

I have the following problem:
When I cut and paste on my linux box, from one vi instance to another, I get all the indents of the 'from' file in addition to the indents that get inserted on newline.

Iow. What started out looking like:
/~~~~~~~~~~~~~~~~~~~~~
    public WOComponent deletePersonAction() {
        DeletePerson nextPage
                = (DeletePerson) pageWithName("DeletePerson");
        nextPage.setPerson(personIter);
        return nextPage;
    }
\_____________________
ends up looking like:
/~~~~~~~~~~~~~~~~~~~~~~
        public WOComponent deletePersonAction() {
                DeletePerson nextPage
                                = (DeletePerson) pageWithName("DeletePerson");
                nextPage.setPerson(personIter);
                return nextPage;
    }
\______________________

So. All existing indents get increased.
Is there any way I can undo this?

Obviously I have my editor set so it automatically indents to the same as the previous line, when I hit return.
I'd like to _not_ have to undo this feature to get the pastes happen properly.

Keep up the great work.

Kind regards.

Luke Vanderfluit.





--
............._..
.|  .| |.|/.|_ .
.|__.|_|.|\.|_ .
:61 421 276 282:
Reply | Threaded
Open this post in threaded view
|

Re: indents when copying and pasting

Pete Johns
On Tue, 2006-08-01 at 10:29:55 +0930, <luke@c...>sent:
>Hi Guys.
>
G'day Luke!

>I really like this list.
>Everyone is so helpful.
>That's not just a suck-up (-:
>
He he. Yeah, I learn a lot from reading this list.

>I have the following problem:
>-----8<-----
>Obviously I have my editor set so it automatically indents to
>the same as the previous line, when I hit return.  I'd like to
>_not_ have to undo this feature to get the pastes happen
>properly.
>
Try toggling the paste option before you paste:

:set paste! paste?

and then toggling it back afterwards. You may want to create a
mapping to do this all in one go, if it's something that you do a
lot.

See :help 'paste'

Hope this helps;


--paj


--
Pete Johns                                   <http://johnsy.com/>
Contact Information                  <http://johnsy.com/contact/>
That Crawley Video             <http://johnsy.com/20060730045800>
DSC00168              <http://johnsy.com/albums/flickr/201519802>


attachment0 (194 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: indents when copying and pasting

A.J.Mechelynck
In reply to this post by luke-44
[hidden email] wrote:

> Hi Guys.
>
> I really like this list.
> Everyone is so helpful.
> That's not just a suck-up (-:
>
> I have the following problem:
> When I cut and paste on my linux box, from one vi instance to another, I get all the indents of the 'from' file in addition to the indents that get inserted on newline.
>
> Iow. What started out looking like:
> /~~~~~~~~~~~~~~~~~~~~~
>     public WOComponent deletePersonAction() {
>         DeletePerson nextPage
>                 = (DeletePerson) pageWithName("DeletePerson");
>         nextPage.setPerson(personIter);
>         return nextPage;
>     }
> \_____________________
> ends up looking like:
> /~~~~~~~~~~~~~~~~~~~~~~
>         public WOComponent deletePersonAction() {
>                 DeletePerson nextPage
>                                 = (DeletePerson) pageWithName("DeletePerson");
>                 nextPage.setPerson(personIter);
>                 return nextPage;
>     }
> \______________________
>
> So. All existing indents get increased.
> Is there any way I can undo this?
>
> Obviously I have my editor set so it automatically indents to the same as the previous line, when I hit return.
> I'd like to _not_ have to undo this feature to get the pastes happen properly.
>
> Keep up the great work.
>
> Kind regards.
>
> Luke Vanderfluit.
>
>
>
>
>

Possibility 1: try ':set paste' temporarily while pasting. (To clear it,
use ':set nopaste'.)

Possibility 2: after pasting, reindent the just pasted text with

        `[=`]

(backtick, open-bracket, equal-sign, backtick, close-bracket).


If one of the above methods doesn't work, try the other.


see
        :help 'paste'
        :help `[
        :help =


Best regards,
Tony.
Reply | Threaded
Open this post in threaded view
|

Re: indents when copying and pasting

Gary Johnson
In reply to this post by luke-44
On 2006-08-01, [hidden email] wrote:

> I have the following problem:
> When I cut and paste on my linux box, from one vi instance to
> another, I get all the indents of the 'from' file in addition to
> the indents that get inserted on newline.

[...]

> Obviously I have my editor set so it automatically indents to the
> same as the previous line, when I hit return.
> I'd like to _not_ have to undo this feature to get the pastes
> happen properly.

If you "set mouse=a", then you can paste (using the middle mouse
button) in either insert or normal mode and then indentation of the
copied text will be preserved, just as though 'paste' had been set
before you pasted.

For those situations where you want the pasted text to be
inserted as though it came from the keyboard, as it does now, simply
hold the shift key down while you press the middle mouse button.

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA