preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.12k stars 486 forks source link

how to sort elements by position? #770

Closed alexzanderr closed 3 years ago

alexzanderr commented 3 years ago

sorry if this is a duplicate

raven42 commented 3 years ago

When in the tagbar window, you can hit the s key to change the sort order. To make this persistent, you can add let g:tagbar_sort = 0 into your .vimrc. See the details in the documentation at doc/tagbar.txt

alexzanderr commented 3 years ago

i sorted them. but i didnt see any option for position. the sort didnt work for position because variables section was printed after every class or function and i had some variables at the beginning of the file.

raven42 commented 3 years ago

The tags are always going to be categorized into a kind as output by ctags. So all variables throughout the entire file that don't have scope defined in the ctags output will show up in a generic variables tag tree hierarchy. There is no way I know of to have a global variable as a root node in the tagbar tree view and to have all tags appear in strict position as they are in the file. Any non-scoped tag will appear in a generic tree node for that tag kind.

For scoped kinds such as classes or similar structures, a root level node is created for that tag kind and any member tag kinds will show up under that node appropriately.

alexzanderr commented 3 years ago

thanks for reply