From 55955fa5c1cf5086af6184a767f22c8e9c57e1df Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 18 Jan 2019 20:41:17 +0300 Subject: [PATCH] add search and find to the documentation Related #68 --- doc.go | 40 +++++++++++++++++++++++++++++++++++++++- docstring.go | 41 ++++++++++++++++++++++++++++++++++++++++- lf.1 | 15 ++++++++++++++- 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/doc.go b/doc.go index b3906eb..9d4d115 100644 --- a/doc.go +++ b/doc.go @@ -102,7 +102,7 @@ The following options can be used to customize the behavior of lf: globsearch boolean (default off) hidden boolean (default off) ignorecase boolean (default on) - ignoredia boolean (default off) (ignore diacritics in latin letters for search and find) + ignoredia boolean (default off) incsearch boolean (default off) preview boolean (default on) reverse boolean (default off) @@ -548,6 +548,44 @@ users. You can define such a command and optionally assign a key if you like. An example command to move selected files to a trash folder and remove files completely are provided in the example configuration file. +Searching Files + +There are two mechanisms implemented in lf to search a file in the current +directory. Searching is the traditional method to move the selection to a file +matching a given pattern. Finding is an alternative way to search for a pattern +possibly using fewer keystrokes. + +Searching mechanism is implemented with commands 'search' (default '/'), +'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' +(default 'N'). You can enable 'globsearch' option to match with a glob pattern. +Globbing supports '*' to match any sequence, '?' to match any character, and +'[...]' or '[^...] to match character sets or ranges. You can enable +'incsearch' option to jump to the current match at each keystroke while typing. +In this mode, you can either use 'cmd-enter' to accept the search or use +'cmd-escape' to cancel the search. Alternatively, you can also map some other +commands with 'cmap' to accept the search and execute the command immediately +afterwards. For example, you can use arrow keys to finish the search with the +following mappings: + + cmap up + cmap down + +Finding mechanism is implemented with commands 'find' (default 'f'), +'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default +','). You can disable 'anchorfind' option to match a pattern at an arbitrary +position in the filename instead of the beginning. You can set the number of +keys to match using 'findlen' option. If you set this value to zero, then the +the keys are read until there is only a single match. Default values of these +two options are set to jump to the first file with the given initial. + +Some options effect both searching and finding. You can disable 'wrapscan' +option to prevent searches to wrap around at the end of the file list. You can +disable 'ignorecase' option to match cases in the pattern and the filename. +This option is already automatically overridden if the pattern contains upper +case characters. You can disable 'smartcase' option to disable this behavior. +Two similar options 'ignoredia' and 'smartdia' are provided to control matching +diacritics in latin letters. + Opening Files You can define a an 'open' command (default 'l') to configure file opening. diff --git a/docstring.go b/docstring.go index 5b8d7c7..2d3a925 100644 --- a/docstring.go +++ b/docstring.go @@ -105,7 +105,7 @@ The following options can be used to customize the behavior of lf: globsearch boolean (default off) hidden boolean (default off) ignorecase boolean (default on) - ignoredia boolean (default off) (ignore diacritics in latin letters for search and find) + ignoredia boolean (default off) incsearch boolean (default off) preview boolean (default on) reverse boolean (default off) @@ -572,6 +572,45 @@ like. An example command to move selected files to a trash folder and remove files completely are provided in the example configuration file. +Searching Files + +There are two mechanisms implemented in lf to search a file in the current +directory. Searching is the traditional method to move the selection to a +file matching a given pattern. Finding is an alternative way to search for a +pattern possibly using fewer keystrokes. + +Searching mechanism is implemented with commands 'search' (default '/'), +'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' +(default 'N'). You can enable 'globsearch' option to match with a glob +pattern. Globbing supports '*' to match any sequence, '?' to match any +character, and '[...]' or '[^...] to match character sets or ranges. You can +enable 'incsearch' option to jump to the current match at each keystroke +while typing. In this mode, you can either use 'cmd-enter' to accept the +search or use 'cmd-escape' to cancel the search. Alternatively, you can also +map some other commands with 'cmap' to accept the search and execute the +command immediately afterwards. For example, you can use arrow keys to +finish the search with the following mappings: + + cmap up + cmap down + +Finding mechanism is implemented with commands 'find' (default 'f'), +'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default +','). You can disable 'anchorfind' option to match a pattern at an arbitrary +position in the filename instead of the beginning. You can set the number of +keys to match using 'findlen' option. If you set this value to zero, then +the the keys are read until there is only a single match. Default values of +these two options are set to jump to the first file with the given initial. + +Some options effect both searching and finding. You can disable 'wrapscan' +option to prevent searches to wrap around at the end of the file list. You +can disable 'ignorecase' option to match cases in the pattern and the +filename. This option is already automatically overridden if the pattern +contains upper case characters. You can disable 'smartcase' option to +disable this behavior. Two similar options 'ignoredia' and 'smartdia' are +provided to control matching diacritics in latin letters. + + Opening Files You can define a an 'open' command (default 'l') to configure file opening. diff --git a/lf.1 b/lf.1 index fa06321..66c11fd 100644 --- a/lf.1 +++ b/lf.1 @@ -117,7 +117,7 @@ The following options can be used to customize the behavior of lf: globsearch boolean (default off) hidden boolean (default off) ignorecase boolean (default on) - ignoredia boolean (default off) (ignore diacritics in latin letters for search and find) + ignoredia boolean (default off) incsearch boolean (default off) preview boolean (default on) reverse boolean (default off) @@ -548,6 +548,19 @@ You can customize these operations by defining a 'paste' command. This is a spec Some useful things are to use the backup option ('--backup') with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls. .PP By default, lf does not provide an actual file deletion command to protect new users. You can define such a command and optionally assign a key if you like. An example command to move selected files to a trash folder and remove files completely are provided in the example configuration file. +.SH SEARCHING FILES +There are two mechanisms implemented in lf to search a file in the current directory. Searching is the traditional method to move the selection to a file matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes. +.PP +Searching mechanism is implemented with commands 'search' (default '/'), 'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' (default 'N'). You can enable 'globsearch' option to match with a glob pattern. Globbing supports '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. You can enable 'incsearch' option to jump to the current match at each keystroke while typing. In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' to cancel the search. Alternatively, you can also map some other commands with 'cmap' to accept the search and execute the command immediately afterwards. For example, you can use arrow keys to finish the search with the following mappings: +.PP +.EX + cmap up + cmap down +.EE +.PP +Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default ','). You can disable 'anchorfind' option to match a pattern at an arbitrary position in the filename instead of the beginning. You can set the number of keys to match using 'findlen' option. If you set this value to zero, then the the keys are read until there is only a single match. Default values of these two options are set to jump to the first file with the given initial. +.PP +Some options effect both searching and finding. You can disable 'wrapscan' option to prevent searches to wrap around at the end of the file list. You can disable 'ignorecase' option to match cases in the pattern and the filename. This option is already automatically overridden if the pattern contains upper case characters. You can disable 'smartcase' option to disable this behavior. Two similar options 'ignoredia' and 'smartdia' are provided to control matching diacritics in latin letters. .SH OPENING FILES You can define a an 'open' command (default 'l') to configure file opening. This command is only called when the current file is not a directory, otherwise the directory is entered instead. You can define it just as you would define any other command: .PP