diff options
author | Teddy Wing | 2020-09-26 22:24:54 +0200 |
---|---|---|
committer | Teddy Wing | 2020-09-29 01:17:26 +0200 |
commit | e07089624f0f8b8ba3f024bbf3c0c1a735522d06 (patch) | |
tree | 0f8a9b7a0d70ae9f5a3e755c038f871e3ba282e1 /plugin/grappele.vim | |
parent | 802d388c9dcc1c75b0acd8bcfe75cbd66c76838d (diff) | |
download | vim-grappele-e07089624f0f8b8ba3f024bbf3c0c1a735522d06.tar.bz2 |
Fix `gG` omap by removing count
Previously, if we stored a number in `s:line`, for example with `17G`,
then `>gG` would cause lines .,17 to be indented 17 times due to the use
of `V`.
When I removed `V` from the omap, any commands using `gG` operated
characterwise, when they should operate linewise.
Found this answer from Liu Sha
(https://stackoverflow.com/users/7026980/liu-sha)
https://stackoverflow.com/questions/4261177/discarding-count-in-expr-mappings/53182922#53182922
that shows how to discard the count for different types of mappings:
> nnoremap <expr> s "@_" . ToNthSpace()
> vnoremap <expr> s "@_" . ToNthSpace()
> onoremap <expr> s printf(":normal %s\<cr>", ToNthSpace())
The `:normal!` looks like it discards the count, so this gives us what
we want. Adapted the suggestion into a new `<expr>` omap that indents
only once for e.g. .,17.
Diffstat (limited to 'plugin/grappele.vim')
-rw-r--r-- | plugin/grappele.vim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/plugin/grappele.vim b/plugin/grappele.vim index e04c8e4..21c5cc7 100644 --- a/plugin/grappele.vim +++ b/plugin/grappele.vim @@ -7,7 +7,7 @@ let g:loaded_grappele = 1 nnoremap <silent> <Plug>Grappele grappele#Grappele(v:count, 'n') nnoremap <silent> <Plug>GrappeleRecall :<C-u>call grappele#Recall('n')<cr> vnoremap <silent> <Plug>GrappeleRecall :<C-u>call grappele#Recall('v')<cr> -onoremap <silent> <Plug>GrappeleRecall :<C-u>call grappele#Recall('o')<cr> +onoremap <silent> <expr> <Plug>GrappeleRecall grappele#ORecall() if !hasmapto('<Plug>Grappele') || !maparg('G', 'n') nnoremap <silent> <expr> G grappele#Grappele(v:count, 'n') |