vim scripting "i want replacement for tnext in cscope" -
i want replace :tnext command cscope not working expectation.
1) below figure shows code working expected. can reach 2nd instance of symbols.
function mycounter() if !exists("s:counter") let s:counter = 1 echo "script executed first time" else let s:counter = s:counter + 1 echo "script executed " . s:counter . " times now" endif endfunction nmap <space>w :ls<cr> nmap <space>i :call mycounter() nmap <space>n :cs find s <c-r>=expand("<cword>")<cr><cr>2<cr>
2) below code not working
function mycounter() if !exists("s:counter") let s:counter = 1 echo "script executed first time" else let s:counter = s:counter + 1 echo "script executed " . s:counter . " times now" endif endfunction nmap <space>w :ls<cr> nmap <space>i :call mycounter() nmap <space>n :cs find s <c-r>=expand("<cword>")<cr><cr><c-r>=str2nr(s:counter)<cr>
the difference between 1 , 2 code snippet =str2nr(s:counter) i.e., dynamic calculation of n instance of symbol upon user press n
before pressing space+n press space+i
please suggest me why 2nd code snippet not working .
you try
nmap <space>n :exec "cs find s" expand("<cword>") "\| norm" str2nr(s:counter)
you seem using <c-r>=str2nr...
in normal mode, not work.
disclaimer: haven't been able test whethr above approach can work.
edit
you might want use cscopetag
setting:
*cscopetag* *cst* if 'cscopetag' set, commands ":tag" , ctrl-] "vim -t" use |:cstag| instead of default :tag behavior. effectively, setting 'cst', search cscope databases tag files. default off. examples: > :set cst :set nocst
this should give rich set of commands working tags, might give ways want (:tjump
, :tnext
etc)
Comments
Post a Comment