aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-10 00:34:11 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-10 00:34:11 +1200
commitbd64d69db2bbb426fe9f4b439af4c3a9ed30f3ee (patch)
treeb3fd81719f7e6ed6bbc0807ef43a2f5c76416364 /vim/plugin
parentAdd vertical_region.vim plugin (diff)
downloaddotfiles-bd64d69db2bbb426fe9f4b439af4c3a9ed30f3ee.tar.gz
dotfiles-bd64d69db2bbb426fe9f4b439af4c3a9ed30f3ee.zip
Use autoloading for vertical_region.vim
Diffstat (limited to 'vim/plugin')
-rw-r--r--vim/plugin/vertical_region.vim50
1 files changed, 6 insertions, 44 deletions
diff --git a/vim/plugin/vertical_region.vim b/vim/plugin/vertical_region.vim
index edd5731a..ddf83a53 100644
--- a/vim/plugin/vertical_region.vim
+++ b/vim/plugin/vertical_region.vim
@@ -14,54 +14,16 @@ if v:version < 700
endif
let g:loaded_vertical_region = 1
-" Function for expression maps returning navigaton keys to press
-function! s:VerticalRegion(count, up, mode) abort
-
- " Get line and column number
- let l:num = line('.')
- let l:col = col('.')
-
- " Move up or down through buffer, counting hits as we go
- let l:hits = 0
- while a:up ? l:num > 1 : l:num < line('$')
-
- " Increment or decrement line number
- let l:num += a:up ? -1 : 1
-
- " If the line has any non-space characters up to the current column, we
- " have a hit; break the loop as soon as we have the count we need
- let l:line = getline(l:num)
- if strpart(l:line, 0, l:col) =~# '\S'
- let l:hits += 1
- if l:hits == a:count
- break
- endif
- endif
-
- endwhile
-
- " 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
- let l:keys .= l:col - 1 . 'l'
- endif
-
- " Return normal mode commands
- return l:keys
-
-endfunction
-
" Define plugin maps
nnoremap <expr> <Plug>(VerticalRegionUpNormal)
- \ <SID>VerticalRegion(v:count1, 1, 'n')
+ \ vertical_region#Map(v:count1, 1, 'n')
nnoremap <expr> <Plug>(VerticalRegionDownNormal)
- \ <SID>VerticalRegion(v:count1, 0, 'n')
+ \ vertical_region#Map(v:count1, 0, 'n')
onoremap <expr> <Plug>(VerticalRegionUpOperator)
- \ <SID>VerticalRegion(v:count1, 1, 'o')
+ \ vertical_region#Map(v:count1, 1, 'o')
onoremap <expr> <Plug>(VerticalRegionDownOperator)
- \ <SID>VerticalRegion(v:count1, 0, 'o')
+ \ vertical_region#Map(v:count1, 0, 'o')
xnoremap <expr> <Plug>(VerticalRegionUpVisual)
- \ <SID>VerticalRegion(v:count1, 1, 'x')
+ \ vertical_region#Map(v:count1, 1, 'x')
xnoremap <expr> <Plug>(VerticalRegionDownVisual)
- \ <SID>VerticalRegion(v:count1, 0, 'x')
+ \ vertical_region#Map(v:count1, 0, 'x')