ThG
ThG

Reputation: 2401

Vim : sorting Todo list

Let us suppose I have a todolist, each line including the same structure of items :

Do something, @priority (e.g. : @1, @2, etc…), §project (e.g. : §vacation, §family, etc…), &category (e.g.: &call, &do, etc…)

Each of these 4 items has a variable length, of course.

I know how to sort on the "Do something" part. But how can I sort such a list by @priority ? or by §project ? or by &category ?

Thanks in advance

Upvotes: 3

Views: 649

Answers (1)

romainl
romainl

Reputation: 196751

I think you should read :help sort, the third example for the /pattern/ argument seems to apply very well to your problem.

Quick and dirty sorting by priority:

:%sort /.\{-}\ze@/

Quick and dirty sorting by project:

:%sort /.\{-}\ze§/

Quick and dirty sorting by category:

:%sort /.\{-}\ze&/

EDIT

The commands above were adhoc modifications of the examples found in the docs. ib is right that they might be too verbose. As per his comment, the commands below are a lot shorter:

:sort /@/
:sort /§/
:sort /&/

END EDIT

Upvotes: 4

Related Questions