How can I search files just like /
command but recursively scanning subfolders. Or maybe there are other approach how can I get a list of files that match some pattern in current folder including all subfolders.
Using Find You can also use the find command followed by the target directory and the file you wish to locate. The command will start in the root directory and recursively search all the subdirectories and locate any file with the specified name.
Alternatively referred to as recursive, recurse is a term used to describe the procedure capable of being repeated. For example, when listing files in a Windows command prompt, you can use the dir /s command to recursively list all files in the current directory and any subdirectories.
Vim offers several commands for searching for files by name: :find, :sfind, :tabfind on the command-line, several normal-mode commands like gf, and others. If you just enter :find filename , Vim will directly open the first file found in your 'path' matching "filename".
There is :fin[d] command for that. Internally it invokes find
utility (this is configurable via 'findprg' option), so you can do everything find
is capable of. That said, in most cases the simple form of the command suffices:
:find *.sh
Note that by default argument is treated as regular file pattern (-name
option of find
), which is different from regular expressions accepted by /
. For searching via regexp, use:
:find -regex '.*_.*'
If you want to scan only specific subfolders, just select them before running the command and search will be limited only to those directories.
:find
command brings up a menu with search results. If you want to process them like regular files (e.g. delete, copy, move), hit b to change list representation.
/
Alternatively you can populate current view with list of files in all subdirectories with command like (see %u):
:!find%u
and then use /
, although this might be less efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With