I often find myself reading other developer's C code containing expressions like
ptr->member1.member2[i].another_member.final_member = 42;
and needing to find out what type final_member
is. Usually what I do is to track down the chain of types using C tags, starting at the declaration of ptr
and digging my way into the chain of members. This is cumbersome and often I'm stuck somewhere scratching my head, asking myself "What was the next member in the chain?" To make matters worse, a simple grep for final_member
in the source tree turns up too many false positives due to the name being reused in more than one struct.
Is there a way to make vim give me the answer directly? I'm willing to install any plugin and even type a few characters while the cursor is on the final_member
or select the whole expression :-) Non-GUI solutions preferred.
If i'm working on a project with several nested structs i add preview
to the completeopt
option.
In combination with the excellent omnicppcomplete
plugin a tiny scratch window pops up if you select an entry in the completion menu. That scratch window shows some properties of the selected tag. Among other things it contains the search pattern for the tag which in case of a struct member usually contains its datatype.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With