parent
e6bf71a53a
commit
36673b255b
@ -1,3 +1,5 @@
|
|||||||
|
let s:enable_highlighting = 1
|
||||||
|
|
||||||
function! s:exchange(x, y, reverse, expand)
|
function! s:exchange(x, y, reverse, expand)
|
||||||
let reg_z = s:save_reg('z')
|
let reg_z = s:save_reg('z')
|
||||||
let reg_unnamed = s:save_reg('"')
|
let reg_unnamed = s:save_reg('"')
|
||||||
@ -143,7 +145,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:highlight_region(region)
|
function! s:highlight_region(region)
|
||||||
let pattern = '\%'.a:region[0].'l\%'.a:region[1].'v\_.\{-}\%'.a:region[2].'l\(\%>'.a:region[3].'v\|$\)'
|
let pattern = '\%'.a:region[0].'l\%'.a:region[1].'v\_.\{-}\%'.a:region[2].'l\(\%>'.a:region[3].'v\|$\)'
|
||||||
return matchadd('ExchangeRegion', pattern)
|
return matchadd('_exchange_region', pattern)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:highlight_clear(match)
|
function! s:highlight_clear(match)
|
||||||
@ -152,6 +154,15 @@ function! s:highlight_clear(match)
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:highlight_toggle(...)
|
||||||
|
if a:0 == 1
|
||||||
|
let s:enable_highlighting = a:1
|
||||||
|
else
|
||||||
|
let s:enable_highlighting = !s:enable_highlighting
|
||||||
|
endif
|
||||||
|
execute 'highlight link _exchange_region' (s:enable_highlighting ? 'ExchangeRegion' : 'None')
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Return < 0 if x comes before y in buffer,
|
" Return < 0 if x comes before y in buffer,
|
||||||
" = 0 if x and y overlap in buffer,
|
" = 0 if x and y overlap in buffer,
|
||||||
" > 0 if x comes after y in buffer
|
" > 0 if x comes after y in buffer
|
||||||
@ -228,6 +239,10 @@ vnoremap <silent> <Plug>(Exchange) :<C-u>call <SID>exchange_set(visualmode(), 1)
|
|||||||
nnoremap <silent> <Plug>(ExchangeClear) :<C-u>call <SID>exchange_clear()<CR>
|
nnoremap <silent> <Plug>(ExchangeClear) :<C-u>call <SID>exchange_clear()<CR>
|
||||||
nnoremap <silent> <Plug>(ExchangeLine) :<C-u>set opfunc=<SID>exchange_set<CR>g@_
|
nnoremap <silent> <Plug>(ExchangeLine) :<C-u>set opfunc=<SID>exchange_set<CR>g@_
|
||||||
|
|
||||||
|
command! XchangeHighlightToggle call s:highlight_toggle()
|
||||||
|
command! XchangeHighlightEnable call s:highlight_toggle(1)
|
||||||
|
command! XchangeHighlightDisable call s:highlight_toggle(0)
|
||||||
|
|
||||||
command! ExchangeClear call s:exchange_clear(1)
|
command! ExchangeClear call s:exchange_clear(1)
|
||||||
command! XchangeClear call s:exchange_clear()
|
command! XchangeClear call s:exchange_clear()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user