I use the following mappings to toggle relative numbers in visual mode:
nnoremap <silent> v v:<c-u>set nonu rnu<cr>gv
nnoremap <silent> V V0:<c-u>set nonu rnu<cr>gv
nnoremap <silent> <c-v> <c-v>:<c-u>set nonu rnu<cr>gv
vnoremap <esc> <esc>:set nornu nu<cr>
I would like to use the same mappings, but add a conditional check before performing the operation to exclude certain buffers types from this behavior.
I tried adding this to a function but was not successful.
Does anyone know how I can achieve this?
set nonu rnu<cr>gv
into a function and tried calling it. What's the problem you're having with understanding the question?