diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-08-10 01:31:43 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-08-10 01:31:43 +1200 |
commit | 50a9a369ad2de035d658010e38e79f3104b78701 (patch) | |
tree | e42878ab58ede2189453c9051220b86eb4d61b44 /autoload/vertical_region.vim | |
parent | First version (diff) | |
download | vim-vertical-region-50a9a369ad2de035d658010e38e79f3104b78701.tar.gz vim-vertical-region-50a9a369ad2de035d658010e38e79f3104b78701.zip |
Correct count handling by dumping <expr> maps
Diffstat (limited to 'autoload/vertical_region.vim')
-rw-r--r-- | autoload/vertical_region.vim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/autoload/vertical_region.vim b/autoload/vertical_region.vim index 6f2cf8d..a872ad6 100644 --- a/autoload/vertical_region.vim +++ b/autoload/vertical_region.vim @@ -1,6 +1,11 @@ -" Function for expression maps returning navigaton keys to press +" Autoloaded function for vertical_region.vim maps function! vertical_region#Map(count, up, mode) abort + " Reselect any selection + if a:mode ==# 'x' + normal! gv + endif + " Get line and column number let l:num = line('.') let l:col = col('.') @@ -27,11 +32,13 @@ function! vertical_region#Map(count, up, mode) abort " If not moving linewise for operator mode and not in first column, move to " same column after line jump; is there a way to do this in one jump? let l:keys = l:num . 'G' - if a:mode !=# 'o' && l:col > 1 + if a:mode ==# 'o' + let l:keys = 'V' . l:keys + elseif l:col > 1 let l:keys .= l:col - 1 . 'l' endif - " Return normal mode commands - return l:keys + " Run normal mode commands + execute 'normal! ' . l:keys endfunction |