How to sort files like `sort` does using the vim's netrw file browser?
Asked Answered
O

3

7

I would like to have my files sorted this way:

abc.c
Makefile
readme.txt

but the netrw file browser sorts them like this (using empty sort sequence):

Makefile
abc.c
readme.txt

How do I fix that?

BTW, it would also be nice to jump to file/directory by typing the first few letters of it's name. Is that possible?

Optimize answered 18/2, 2014 at 13:58 Comment(0)
J
11

netrw indeed can do case-insensitive sorting (which I suppose is what you want): Put the following into your ~/.vimrc:

let g:netrw_sort_options = "i"

As the netrw file listing is a plain Vim buffer, you can quickly locate entries via the default / search command. If you want a solution that filters the list of candidates as you type, you need a different plugin like FuzzyFinder or Command-T.

Jaxartes answered 18/2, 2014 at 14:9 Comment(2)
Beautiful! Thank you, it somehow slipped my mind I could just search the buffer just like a text file.Optimize
This feature is mentioned in netrw's help, too: :help g:netrw_sort_options, at least with v153s.Auriscope
H
5

Sorting in netrw is controlled two ways. You can use the s key to toggle between sorting by size, time, and name. If that doesn't do what you want, the sorting sequence in netrw can also be controlled by a variable named g:netrw_sort_sequence. The default should be suitable for what you want, but it can be changed by setting the variable manually. You can read the Vim help topic netrw_sort_sequence for more info (:help netrw_sort_sequence)

Harrelson answered 18/2, 2014 at 14:9 Comment(0)
A
1

usually Linux collation is POSIX so i think you need just to change collation like this

export LC_COLLATE=C

issue the command on the terminal wich runs the VIM or put it in .profile or .bashrc to be be executed always

Aiguille answered 18/2, 2014 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.