VS Code: Search multiple directories - visual-studio-code

When searching, VS Code has the ability to list files to include to scope the search. This is used by default when using the "find in folder" feature. For example, searching src results in ./src as the files to include.
Is there a syntax I can use to list multiple directories here? For example, I want to search ./src and ./lib in one search.

Did you try a comma like ./dir1, ./dir2? For me it seems to work

By the way, here is the documentation of 'files to include': https://code.visualstudio.com/Docs/editor/codebasics#_advanced-search-options
In particular, you can use glob notation. Also, VS Code will include/exclude certain directories or files by default, depending on your settings.json, in case anyone still sees unexpected behaviour.

Related

How do you include git ignored files in VSCode quick search

Working in PHP, my vendor folder is ignored by git.
If I press Command-P, how would I include ignored files in the quick search?
You can specify the state of inclusion for items in quick open using the following workspace (or otherwise) setting : search.exclude
Per their docs:
Configure glob patterns for excluding files and folders in fulltext searches and quick open. Inherits all glob patterns from the #files.exclude# setting
Edit: I interpreted what you were asking incompletely with my initial response, but will leave it for future question seekers and also because you can use in tandem with the following.
If you would like to make sure ignored files are present in quick open use one of the following, or both, depending on the scope of which it's ignored:
"search.useIgnoreFiles": false,
"search.useGlobalIgnoreFiles": false

TYPO3 Filecollection, Type "Folder from Storage" - Recursion possible?

is there a way to get a file list recursively based on one file collection that points to a directory in fileadmin?
Currently I only got it to work with files directly in that directory, not also with files in sub-directories of that directory.
So instead of setting lots of file collections for each (sub directory)
I'd like to set only the "top"level directory (here "Kurs77") and have the files, even from sub directories, displayed.
Reason is, editors may add an unknown amount of (sub)sdirectories, and I'd like to have the files automagically displayed in the file list in the front end -- without the need to create an increasing amount of file collections.
cheers,
Tom
it seems that this is a missing feature. Check out https://forge.typo3.org/issues/61238. It seems that the underlaying API is able to do that.
So one solution would be to use TypoScript to make that work.
To give the correct answer now: The recursive option is of course available but it is part of the sys_file_collection record.
In TYPO3 9 this is working out of the box. pity is not showing folder as title, but recursive works:

Documentation for nautilus and GIO's .hidden file feature?

I just discovered some mentions of how nautilus used to read files named .hidden and hide files matching the patterns listed in them, and at some point that feature was moved to GIO g_file_info_get_is_hidden. However, I haven't been able to get it to work. If I put the exact name of a file into .hidden, it does get hidden, but I'd really like to be able to use a pattern. I can't find any solid or recent documentation about how this feature is supposed to work.
I'd particularly like to hide files matching hg-checkexec-*. Mercurial running under Emacs periodically creates bunches of these temporary files and they gum up my nautilus view.
Is this feature documented anywhere? How is it supposed to work?
Looking at the code, .hidden files as implemented in GIO support one filename per line, with no support for patterns. A .hidden file cannot list files in subdirectories — only those in the same directory.
I don’t know of any documentation about the feature. Please file a bug about adding it.
As a complement to Philip Withnall's answer, I've dived further into the source code, specifically the functions read_hidden_file() and file_is_hidden():
read_hidden_file() basically parses the .hidden in a directory and stores each line in as a key in a GLib HashTable object.
The object is created using g_hash_table_new_full() with parameters g_str_hash, g_str_equal, g_free, NULL. This mean keys are plain strings with comparison being a plain (case-sensitive) string equality, so no globs, regex or any patterns support.
It is populated using g_hash_table_add(), so not used as a key/value pair table but rather as a plain set, with keys being the elements themselves.
file_is_hidden() is called for each content (file or sub-directory) in a given directory. It uses g_hash_table_contains() to check if the file's basename is a key in above object, so no pattern search whatsoever.
So, as Phillip concluded, it seems there is indeed no support for any kind of globs, regexes or pattern seach in .hidden files. I would also die for a .gitignore-like syntax.

vifm search files in subfolders

How can I search files just like with / command but recursively scanning subfolders?
Or maybe there are other approaches to get a list of files that match some pattern in the current folder including all subfolders.
:find command
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.
Alternative that uses /
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.

How to search a text among c files under a directory

I've looked through several similar questions, but either I didn't understand their answer or my question is different than theirs. So, I have a project contains many subdirecties and different type of files. I would like to search a function name among those .C files only.
Some information on the web suggest to use "Esc x dired-do-query-replace-regexp". However, this will search not just C files, but also other file like .elf which isn't helpfule in my case. Other people sugget to use TAG function, but it will require me to type "etags *.c" for every subdirectory which is also impossible.
How should I do this while working on those large scale software project?
Thanks
Lee
Use ack-grep on linux
ack-grep "keyword" -G *.c
My favorite: igrep-find, found in the package igrep.el. Usage is:
M-x igrep-find some_thing RET *.C
There's the built in grep-find, docs here, but I find it awkward to use.
For a more general answer, see this similar question: Using Emacs For Big Big Projects.
if you're on linux, you can use grep to find files with a certain text in them. you would then do this outside of emacs, in your shell/command prompt. here's a nice syntax:
grep --color=auto --include=*.c -iRnH 'string to search for' /dir/to/search/
the directory to search can be specified relative, so if you're in the directory you want to use as the root directory for your recursive search, you can just skip the whole directory address and specify a single dot.
grep --color=auto --include=*.c -iRnH 'string to search for' .
the part --color=auto makes some text highlighted. --include=*.c is the part that specifies what files to search. in this case, only files with the c-extension. the flag i makes stuff case insensitive, the flag R makes the search recursive, the flag n adds the line number to the report, and the flag H adds the file path to the report.
To breed find and grep there is find-grep function, there you can change the invocation string to find . -name *.c etc. Make it a function, if You like. Then You use eg. C-x` et al. to navigate the results.
To search among the files in one directory i use lgrep, it prompts you in which files to search.
You can use cscope and xcscope.el : http://www.emacswiki.org/emacs/CScopeAndEmacs
Try with dired: place the cursor on the directory name to search, type A and in the minibuffer the text to find.