When opening C/C++ source code in Vim, if you open the tagbar plugin, the display order of functions in the tagbar is different from the display order in the C/C++ source file. I wonder why.

1 Answer 1


Both types of sorting are possible:

  • Alphabetically (the default)
  • By position in the file

You can switch the sorting criteria using the s key.

You can control the default using g:tagbar_sort.

To make the default to "by position in the file" set:

let g:tagbar_sort = 0

Remark: For Python class will be always before functions (since tagbar group classes and functions)

  • Thank you! I now can control the tagbar sorting. Thank you!
    – Jumogehn
    Commented Dec 20, 2023 at 5:55
  • Thank fie the feedback :-) I'm glad I could help you. Commented Dec 20, 2023 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.