Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist highlighting status when changing color schemes #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions plugin/exchange.vim
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,15 @@ function! s:highlight_toggle(...)
else
let s:enable_highlighting = !s:enable_highlighting
endif
execute 'highlight link _exchange_region' (s:enable_highlighting ? 'ExchangeRegion' : 'None')
augroup vim_exchange
autocmd!
if s:enable_highlighting
autocmd ColorScheme * highlight link _exchange_region ExchangeRegion
else
highlight link _exchange_region None
endif
augroup END
silent doautocmd vim_exchange ColorScheme
endfunction

" Return < 0 if x comes before y in buffer,
Expand Down Expand Up @@ -325,7 +333,6 @@ function! s:get_setting(setting, default)
endfunction

highlight default link ExchangeRegion IncSearch
highlight default link _exchange_region ExchangeRegion

nnoremap <silent> <expr> <Plug>(Exchange) ':<C-u>set operatorfunc=<SID>exchange_set<CR>'.(v:count1 == 1 ? '' : v:count1).'g@'
vnoremap <silent> <Plug>(Exchange) :<C-u>call <SID>exchange_set(visualmode(), 1)<CR>
Expand Down