将定义的类型着色为类型



是否有任何方法添加语法着色的新类型定义与typedef语句在C?

typedef struct {
    int a,b;
} MyStruct;
MyStruct *InitMyStruct(MyStruct *struct, int a, int b);
    ^         ^           ^               ^      ^
    +---------+-----------+               +------+
    Same Color                             Correct type color

如果这是不可能的原生(我猜是这样),有没有任何插件使这个视觉线索的工作?

我在Vim的帮助中找到了我的问题的确切解决方案,我在这里发布它,以防将来有人需要它。这正是我想要的:一种阅读代码并相应地突出显示的方法。

syntax.txt

第15节:突出显示标签

[...]
Only highlighting typedefs, unions and structs can be done too.  For this you
must use Exuberant ctags (found at http://ctags.sf.net).
Put these lines in your Makefile:
# Make a highlight file for types.  Requires Exuberant ctags and awk
types: types.vim
types.vim: *.[ch]
        ctags --c-kinds=gstu -o- *.[ch] |
                awk 'BEGIN{printf("syntax keyword Typet")}
                        {printf("%s ", $$1)}END{print ""}' > $@
And put these lines in your .vimrc: >
   " load the types.vim highlighting file, if it exists
   autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
   autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
   autocmd BufRead,BufNewFile *.[ch]   exe 'so ' . fname
   autocmd BufRead,BufNewFile *.[ch] endif

相关内容

  • 没有找到相关文章

最新更新