Hari Sundararajan
Hari Sundararajan

Reputation: 678

VIM file explorer plugin that allows sorting by type

I don't really mind if I have to use NerdTree or netrw or CtrlP or whatever. I want to be able to sort by type and hide files by type as needed. The hide files part is done through regular expression and all's well. What about sorting by type?

By type I mean extension. I want to ask the plugin to show me all .c files followed by all .h files. Then, at another point in time, I want it to show me files in alphabetical order.

Any thoughts on how I can accomplish this?

Upvotes: 0

Views: 726

Answers (2)

user21497
user21497

Reputation: 1181

This feature is available with netrw: see :help netrw-sort-sequence. For example, try:

let g:netrw_sort_sequence='\.c$,\.h$,*'

Upvotes: 1

Ingo Karkat
Ingo Karkat

Reputation: 172688

I guess that would require an enhancement to either plugin, and I would suggest you contact the authors with such request or patch.

At least for NERDTree, you can sort of emulate that with the following (created) config. Note that this just considers the first character of the file extension for sorting.

let g:NERDTreeSortOrder = map(range(0, 25), '"\\." . nr2char(char2nr("a") + v:val) . "[^.]*$"')

Upvotes: 2

Related Questions