Open
Description
I recently asked for a feature where activating the InverseSearch functionality would centre and highlight the area in the document where the location was being referenced. @lervag implemented a very nice attempt at this: #3038
Here was the prototype:
augroup vimtex_event_5
au!
au User VimtexEventViewReverse call CenterAndFlash()
augroup END
function! CenterAndFlash() abort
" Center on cursor position
normal! zz
let save_cursorline_state = &cursorline
" Add simple flashing effect, see
" * https://vi.stackexchange.com/a/3481/29697
" * https://stackoverflow.com/a/33775128/38281
for i in range(1, 3)
set cursorline
redraw
sleep 200m
set nocursorline
redraw
sleep 200m
endfor
let &cursorline = save_cursorline_state
endfunction
This feature has been very valuable to me during testing. The InverseSearch functionality can sometimes be flakey: for example, it can be unclear if your PDF is 'focused', which means you may need to click 2-3 times for the search to happen. It can be also be hard to detect where in a tex document it is referencing.
I want to propose that this feature be implemented into the core vimtex functionality. Some additional thoughts:
- Can the centering operation be made with more visual feedback. Instead of a jump, can the tex document be scrolled, similar to the vim-smoothie plugin? This gives really good visual feedback: it allows you to discern where the document is being jumped to, and the amount it has moved.
- Can we implement more distinct highlighting? The current highlight uses the cursorline colour, which is usually very subtle. Some latex editors that do this won't use a highlight but instead use something like a big red dot.