Menu

Navigating long hierarchical lists

Viki
2010-11-29
2013-04-17
  • Charles Hogg

    Charles Hogg - 2010-11-29

    I find I'm using a lot of long, hierarchical lists.  For hierarchical chapters/sections, navigation is very easy and powerful using vim's folding commands.  Is there anything similar for the lists?  Something like "jump to first/last/next/prev element", "jump to the next-outermost level", etc.?

    So far I've been relying on standard vim navigation (jumping to line numbers, etc.), but there's clearly this structure to the document, and it'd be great to take more direct advantage of it.

    Any ideas?

     
  • Tom Link

    Tom Link - 2010-12-02

    You can search for the list markers or paragraph boundaries and map that to a key. Maybe something like this:

    ^\(\n\n\+\|\s\+\(#\u\d\|\|.\)\s\)

    This should match either paragraphs (which doesn't work that well with that regexp but it's only meant to be an example) or list items. If you want to take into account list levels, you'd have to limit the amount of \s in the second branch of that regexp.

    If you find yourself using many lists, you might also want to change the fold method. One of those methods in ftplugin/viki.vim creates folds for list items. It didn't work well though and I cannot remember which one it was. An alternative approach would be to use indent-based folds.

    I personally separate groups of list items with an empty line and then use paragraph movements to move between list items.

    HTH

     

Log in to post a comment.