Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

netrw

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?

like image 880
Egor Tensin Avatar asked Feb 18 '14 13:02

Egor Tensin


3 Answers

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.

like image 70
Ingo Karkat Avatar answered Nov 15 '22 10:11

Ingo Karkat


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)

like image 37
mattr- Avatar answered Nov 15 '22 08:11

mattr-


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

like image 22
Saddam Abu Ghaida Avatar answered Nov 15 '22 08:11

Saddam Abu Ghaida