scrolljump and paste ?

12 views
Skip to first unread message

M Kelly

unread,
May 10, 2019, 8:30:19 PM5/10/19
to vim_use
Hi,

I set scrolljump=-50, it works well for me.
But sometimes when I paste it is annoying when the cursor jumps.
I have experimented with:

au InsertEnter * let &scrolljump=1
au InsertLeave * let &scrolljump=-50

but this doesn't seem to affect pasting.
Does anyone know of or have a suggestion for this ?
Could I remap 'p' to set scrolljump=1 then p again ?

thx for all things vim,
-mark

Tony Mechelynck

unread,
May 10, 2019, 8:46:56 PM5/10/19
to vim...@googlegroups.com
I suppose you could, but this would not solve the question of how to
come back, or of how to paste before the cursor.

I suggest the following (untested, assumes 'nocompatible'):

:map <F5> :set scrolljump=1<CR>p
:map <S-F5> :set scrolljump=1<CR>P
:map <F6> :set scrolljump=-50<CR>

Best regards,
Tony.

M Kelly

unread,
May 10, 2019, 9:08:30 PM5/10/19
to vim_use
> :map <F5> :set scrolljump=1<CR>p
> :map <S-F5> :set scrolljump=1<CR>P
> :map <F6> :set scrolljump=-50<CR>

Hi,

Thanks Tony.
Is there a way around the recursion of mapping p to call a function that
issues a p between setting scrolljump values ? Perhaps with an alias ?

thx,
-mark

M Kelly

unread,
May 10, 2019, 9:28:17 PM5/10/19
to vim_use
> Thanks Tony.
> Is there a way around the recursion of mapping p to call a function that
> issues a p between setting scrolljump values ? Perhaps with an alias ?

Hi,

Something weird, like this ???

function! MyPaste() abort
nnoremap <silent> <buffer> p p
let &scrolljump=1
execute "normal p"
let &scrolljump=-50
nnoremap <silent> <buffer> p :call MyPaste()<CR>
endfunction

nnoremap <silent> <buffer> p :call MyPaste()<CR>

thx,
-m

Tony Mechelynck

unread,
May 11, 2019, 2:25:30 AM5/11/19
to vim...@googlegroups.com
By using :noremap (and friends), the {rhs} is not inspected for
further mappings (i.e., even if it contains its own {lhs} or that of
another mapping, it remains unchanged).
Reply all
Reply to author
Forward
0 new messages