Sort (selected) lines

As Obsidian is all about linking files and making lists there should be a command ‘Sort (selected) lines’ to sort selected lines alphabetically: links, lists, checkboxes etc.

For example:

[[Note taking]]


- first line
- second line
- third line


- [ ] task
- [x] finished task
- [ ] another task
- [x] another finished task

Yes please! I have many long lists that I’d like to sort. Currently I select, copy, paste into notepad++, sort, select, copy, paste back into Obsidian. This doesn’t work if I need to sort an outline and keep subitems with their parent item.

You can open your Markdown files directly in a text editor. No need to copy/paste in and out of the app.

For those who don’t mind Vim, the Vim keybindings has a sort command.

Sort line 3 to 8, and leave 10 to 13 alone:



Oh! Thank you. I actually love VIM. I tried it but some keys worked like VIM and some keys worked like Obsidian and I got frustrated. Is there a definitive document for Obsidian’s VIM mode? edit: I just realized you are talking about actual VIM not Obsidian’s VIM mode.

No, I’m talking about Obsidian’s Vim key bindings. But OP asked for a feature that can work on selection.

Actually, I figured it out. It does match Vim’s visual selection sort. I just had a space between the range and sort, which wasn’t working.

How to sort in Vim mode by selection:

  1. Select the lines you want using Vim Visual Mode.
  2. :'<,'>sort

@ControlAltPete as far as I understand, Vim Mode is implemented via CodeMirror’s Vim plugin. And that project does not have an active maintainer according to this page:

1 Like

Thanks! For anyone reading this the complete list of key maps is at (scroll down just a bit to defaultKeyMap).
So I assume VIM will not do the right thing if I try to sort an indented outline… It would break apart subitems from parent items.

Edit: unfortunately that source code is not accurate. I’m not sure how or why. But the source code has no mention of the folding keys: zc zo zC zO but testing shows they WORK. Likewise the source code has no mention of the folding keys: zr zm zR zM but testing shows they do NOT work. :frowning:

This is a great idea! True we can use Vim bindings for now but this sort feature would be great in a UI menu natively in Obsidian or at least in a plugin.

This feature is provided by plugin GitHub - Vinzent03/obsidian-sort-and-permute-lines: Sort and Permute lines in whole file or selection.
So IMHO, this feature request could be archived.

See also very similar request and relevant discussion/comments:

1 Like