开发者

Reliable C context window

I've recently started using the ctx Vim addon. This addon provides a "context" window 开发者_开发问答that displays the layers of scope — function definitions, for loops, if statements, etc. — down to the current line. It's really great! ..in theory. In practice, I'm finding that it's not all that reliable. I may just have bad luck; I've really only tried to use it on one file so far.

For example, within the ExpandFromContext function in vim's src/ex_getln.c, the function signature is not displayed, just the opening brace.

This addon is pretty old (last update 2002) and the author seems to have moved on to decidedly non-C things (looks like mostly clojure development). So as such, there doesn't seem to be much point in filing a bug report.

Is there a fork of this addon or another one which provides more reliable parsing?


Although basic this function has been very helpful to me. Got it from a friend who got it from a website so not claiming any authorship. Add it to your vimrc for getting the current function you're in. I've only used it in C/C++:

fun! ShowFuncName()
    let lnum = line(".")
    let col = col(".")
    echohl ModeMsg
    echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
    echohl None
    call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun

noremap <silent> <F3> :call ShowFuncName() <CR>


May be the plug-in is also obsolete because there are some good other Vim features in the meanwhile, at least - folding, 6 methods (:help folding), - working with text objects (:help text-objects).


Maybe SrcExpl is suitable for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜