Saturday, April 14, 2012

Re: How to do a relative paste?

On Tue, 10 Apr 2012, AK wrote:

> On 04/10/2012 06:22 PM, Benjamin R. Haskell wrote:
>> On Tue, 10 Apr 2012, AK wrote:
>>
>>> Hi, how can I paste keeping both the original indent and the indent
>>> of pasted text, but not increasing with each line?
>>
>> It sounds like you want ]p
>>
>> See: :help ]p
>
>
> That doesn't work for me when pasting from * register. Here's what I
> end up with:
>
> #ribbon {
> position:absolute;
> top:-3px;
> left:-15px;
> z-index:500;
> }
>
> when desired output is:
>
> #ribbon {
> position:absolute;
> top:-3px;
> left:-15px;
> z-index:500;
> }

What kind of file are you editing? That works fine for me in all
of:
- HTML (within a <style> element)
- PHP (within a <style> element)
- CSS (anywhere)

What do you mean by "pasting from * register"? It didn't behave any
differently for me regardless of what register I used.

Is the source content properly indented? ]p won't fix the indentation,
except to modify it the same way the first line needs to be modified to
be properly indented in context.

So, e.g., if you paste (with ]p), the following:

#blah {
width: 100%;
height: 100%; /* too much indent */
}

After:
#something {
width: 100%;
}

You'll end up with:
#something {
width: 100%;
}
#blah {
width: 100%;
height: 100%; /* (still) too much indent */
}

Similarly, pasting:

#blah { /* already indented */
width: 100%;
height: 100%; /* too much indent */
}

After:

#something {
width: 100%;
}

Yields:

#something {
width: 100%;
}
#blah {
width: 100%;
height: 100%; /* (still) too much indent */
}

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: