From 3483e377e93e6381e2fea236ceb0e7d2991aa29e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Sep 2020 23:28:36 +0200 Subject: Add operator pending and visual mode `G` mappings I previously added o- and v-maps for the `gG` mapping, but hadn't done so for `G`. This change allows us to reuse lines given to `G` from other modes. For example: 173>>..ygG Didn't use `` mappings here because after testing them, there was a noticeable delay. Found 07a75d523eadaf1027aa8bf287256602ad05f97f, which describes a performance penalty, so used direct mappings instead. Kept the `Grappele` mapping for a measure of backward compatibility. --- autoload/grappele.vim | 5 ++++- plugin/grappele.vim | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/autoload/grappele.vim b/autoload/grappele.vim index f9c7bd3..74af532 100644 --- a/autoload/grappele.vim +++ b/autoload/grappele.vim @@ -4,10 +4,13 @@ function! grappele#Grappele(line, ...) let l:column_offset = 0 let l:mode = get(a:, 1, '') + let l:visualmode = get(a:, 2, '') normal! m' if l:mode ==# 'v' + execute 'normal! ' . l:visualmode + elseif l:mode ==# 'o' normal! V endif @@ -28,6 +31,6 @@ endfunction function! grappele#Recall(mode) if exists('s:line') - call grappele#Grappele(s:line, a:mode) + call grappele#Grappele(s:line, a:mode, visualmode()) endif endfunction diff --git a/plugin/grappele.vim b/plugin/grappele.vim index a0f0aa2..9ab1400 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -4,13 +4,22 @@ endif let g:loaded_grappele = 1 -nnoremap Grappele :call grappele#Grappele(v:count) +nnoremap Grappele :call grappele#Grappele(v:count, 'n') nnoremap GrappeleRecall :call grappele#Recall('n') vnoremap GrappeleRecall :call grappele#Recall('v') onoremap GrappeleRecall :call grappele#Recall('o') if !hasmapto('Grappele') || !maparg('G', 'n') - nnoremap G :call grappele#Grappele(v:count) + nnoremap G :call grappele#Grappele(v:count, 'n') +endif + +if !hasmapto('Grappele') || !maparg('G', 'v') + vnoremap G + \ :call grappele#Grappele(v:count, 'v', visualmode()) +endif + +if !hasmapto('Grappele') || !maparg('G', 'o') + onoremap G :call grappele#Grappele(v:count, 'o') endif if !hasmapto('GrappeleRecall') || !maparg('gG', 'n') -- cgit v1.2.3