Tuesday, April 10, 2012

Re: How to do a relative paste?

El Miércoles, 11 de abril de 2012, AK escribió:
> 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;
> }

Unfortunately, this kind of stuff depends a lot on a good indent file. Still, I
think the best way to do it is not with maps that adjust indentation, since
that might break the previous indentation of whatever you are pasting.

The best solution I have found so far is the one implemented with this plugin:
https://github.com/sickill/vim-pasta.git

It does a very simple but smart thing: before pasting, adds a line with o/O
that later is deleted.

I found it works much better than I initially expected. And if you are like
me, you would still want a map that selects what you just pasted, so you can
fine tune if needed:

nnoremap <expr> <leader>m "`[" . strpart(getregtype(), 0, 1) . "`]"

Greetings.

--
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net

--
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: