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

StackOverflow https://stackoverflow.com/questions/21856038

  •  13-10-2022
  •  | 
  •  

سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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)

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top