0

I find that the default indentation support for pasting is lacking. For example , If I use ]p for the following(copied using V) :

        try:
            l=None
            if 1:
                df = vcbcvbcvb

            return l, df

When I am over this line:

def save(fn):

I get the same thing but when the try at all not indented .

def save(fn):
try:
    l=None
    if 1:
        df = vcbcvbcvb

    return l, df

Now , I tried to fix it by:

nnoremap <expr> ]p @+ =~ ".*\n$" ?  "]p==" : "o<C-R>+<ESC>"

which is not enough because the == should be on all the pasted text.

Is there a plugin that does complete support or could you suggest just a concrete solution.

1 Answer 1

0

Found myself implementing the code.

It first pastes then fixes the indentation correctly as far as I could see.

function! PasteFormat(x)
    let l=@+
    let l=len(split(l,"\n"))-1
    return a:x."V".string(l).'j='
endfunction

nnoremap <expr> ]p @+ =~ ".*\n$" ?  PasteFormat("p") : "o<C-R>+<ESC>"
nnoremap <expr> ]P @+ =~ ".*\n$" ?  PasteFormat("P") : "O<C-R>+<ESC>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.