README.md | 4 ++-- nnn.1 | 15 ++++++--------- src/nnn.c | 16 ++++++++-------- diff --git a/README.md b/README.md index 8264418796cb47f0885b594f16f4541918ec91ee..71f9ff2d8e651c4fe56d4bb7b847dbcc6c91c4bd 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ - Case-insensitive version (_aka_ natural) sort - By file name, modification/access time, size, extension - Search - Instant filtering with *search-as-you-type* - - Regex (default) and substring match + - Regex and substring (default) matches - Subtree search to open or edit files (using plugin) - Mimes - Open with desktop opener or specify a custom app @@ -189,6 +189,7 @@ -d detail mode -e name load session by name -E use EDITOR for undetached edits -f run filter as cmd on prompt key + -g regex filters [default: string] -H show hidden files -i nav-as-you-type mode -K detect key collision @@ -197,7 +198,6 @@ -o open files on Enter -p file selection file [stdout if '-'] -r use advcpmv patched cp, mv -R disable rollover at edges - -s string filters [default: regex] -S du mode -t disable dir auto-select -v show version diff --git a/nnn.1 b/nnn.1 index 8130587dc5ba0ef51ce63278d508f08e10d75606..5345ba89b1152f978b8bc1effd8366856483ef1e 100644 --- a/nnn.1 +++ b/nnn.1 @@ -13,6 +13,7 @@ .Op Ar -d .Op Ar -e name .Op Ar -E .Op Ar -f +.Op Ar -g .Op Ar -H .Op Ar -i .Op Ar -K @@ -20,7 +21,6 @@ .Op Ar -n .Op Ar -p file .Op Ar -r .Op Ar -R -.Op Ar -s .Op Ar -S .Op Ar -v .Op Ar -x @@ -65,6 +65,9 @@ .Pp .Fl f run filter as command when the prompt key is pressed .Pp +.Fl g + use regex filters instead of substring match +.Pp .Fl H show hidden files .Pp @@ -88,9 +91,6 @@ show cp, mv progress (Linux-only, needs advcpmv; '^T' shows the progress on BSD/macOS) .Pp .Fl R disable rollover at edges -.Pp -.Fl s - use substring match for filters instead of regex .Pp .Fl S start in disk usage analyzer mode @@ -137,10 +137,9 @@ .Pp All the session files are located in the \fB${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions\fR directory by the session name. "@" is the "last session" file. .Sh FILTERS -Filters support regexes (default) to instantly (search-as-you-type) list the matching -entries in the current directory. +Filters are substrings to find matching entries in the current directory instantly (search-as-you-type). There is a program option to use regex filters. .Pp -Common use cases: +Common regex use cases: .Pp (1) To list all matches starting with the filter expression, start the expression with a '^' (caret) symbol. @@ -148,8 +147,6 @@ .br (2) Type '\\.mkv' to list all MKV files. .br (3) Use '.*' to match any character (\fIsort of\fR fuzzy search). -.Pp -There is a program option to filter entries by substring match instead of regex. .Pp There is a program option to execute the current filter as a command when the prompt key is pressed. .Pp diff --git a/src/nnn.c b/src/nnn.c index c0beb5c5e9c723633f0a5b166d53a6958939c583..6629d99ae62a1c353513b49385af1727a446f80c 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -293,7 +293,7 @@ 0, /* metaviewer */ 0, /* useeditor */ 0, /* runplugin */ 0, /* runctx */ - 1, /* filter_re */ + 0, /* filter_re */ 0, /* filtercmd */ 0, /* trash */ 1, /* mtime */ @@ -1804,7 +1804,7 @@ { return strcasestr(fname, fltrexp->str) != NULL; } -static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_re; +static int (*filterfn)(const fltrexp_t *fltr, const char *fname) = &visible_str; static int entrycmp(const void *va, const void *vb) { @@ -5449,6 +5449,7 @@ " -d detail mode\n" " -e name load session by name\n" " -E use EDITOR for undetached edits\n" " -f run filter as cmd on prompt key\n" + " -g regex filters [default: string]\n" " -H show hidden files\n" " -i nav-as-you-type mode\n" " -K detect key collision\n" @@ -5457,7 +5458,6 @@ " -o open files on Enter\n" " -p file selection file [stdout if '-']\n" " -r use advcpmv patched cp, mv\n" " -R disable rollover at edges\n" - " -s string filters [default: regex]\n" " -S du mode\n" " -t disable dir auto-select\n" " -v show version\n" @@ -5604,7 +5604,7 @@ #ifdef __linux__ bool progress = FALSE; #endif - while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rRstvxh")) != -1) { + while ((opt = getopt(argc, argv, "HSKiab:cde:Efgnop:rRtvxh")) != -1) { switch (opt) { case 'S': cfg.blkorder = 1; @@ -5634,6 +5634,10 @@ cfg.waitedit = 1; break; case 'f': cfg.filtercmd = 1; + break; + case 'g': + cfg.filter_re = 1; + filterfn = &visible_re; break; case 'H': cfg.showhidden = 1; @@ -5668,10 +5672,6 @@ #endif break; case 'R': cfg.rollover = 0; - break; - case 's': - cfg.filter_re = 0; - filterfn = &visible_str; break; case 't': cfg.autoselect = 0;