context.vim icon indicating copy to clipboard operation
context.vim copied to clipboard

Is there mapping to jump to start of context block?

Open dragonxlwang opened this issue 1 year ago • 1 comments

noob question but couldn't find related in the doc. Asking if there's a key mapping for jump to start of the block? Thanks!

dragonxlwang avatar Sep 18 '24 19:09 dragonxlwang

You can create your own mapping in your vimrc by using w:context variable created by the plugin


function! ContextJumpToNearest()
    if exists("w:context")  " variable is local to current window, and contains infos about context preview
        if len(w:context.lines) > 0
            " 0 - manually add current pos to jmp history
            normal! m'
            " 1 - jump to context line
            let nearest_context_line = w:context.lines[-1][0].number
            let col = indent(nearest_context_line) + 1
            call cursor(nearest_context_line, col)
        else
            echo "cannot jump: no context window currently displayed"
        endif
    else
        echo "cannot jump: context.vim disabled"
    endif
endfunction
nnoremap gc :call ContextJumpToNearest()<CR>

jrmd54 avatar Nov 26 '25 17:11 jrmd54