preservim / tagbar

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

Allow folding/unfolding with h/j and arrow left/right #884

Closed cheater closed 5 months ago

cheater commented 5 months ago

There isn't much of a reason to use h/j in the tagbar. Even if you need to scroll you can use w, W, , and so on.

Your hand is always over them h/j, and they're much easier to use than - and +. Similarly with the arrows if you're using arrows to navigate.

That would make navigation much, much smoother.

Should probably be a setting like g:fold_with_hl_and_arrows that defaults to 1

raven42 commented 5 months ago

This would be best left to a custom configuration. This can be done using the following .vimrc configuration.

let g:tagbar_map_openfold = ['l', '+', '<kPlus>', 'zo']
let g:tagbar_map_closefold = ['h', '-', '<kMinus>', 'zc']

This will use the h and l keys like you are indicating along with the other default values that are currently defined. You could similarly add the arrow keys into the list as well.

As a general rule for interface design, basic navigation should never be overridden unless it is a widely known and standard type of change (for example, using the mouse to control the camera in FPS games). So while I agree that there isn't a lot of reason to move the cursor left/right in the tagbar window, we shouldn't change the default behavior of what people expect.

Note: There is also the o keymap shortcut that toggles the fold as well, so even with the default tagbar configuration, there is a very easy to reach keymap to do what you are asking.

cheater commented 5 months ago

that's actually perfect, thank you so much. i did only want to set those for myself. i didn't know there was a setting, but that's great. thanks!