I tried pressing Shift twice twice to "Search Everywhere" but it is not working as expected. I want to search through all files basically an equivalent of Ctrl + F that not only searches through the current file but ALL files in ones project.
How can I do that?
Please try Edit | Find | Find in Path (Ctrl+Shift+F)
See https://www.jetbrains.com/help/webstorm/2018.2/find-and-replace-in-path.html
Related
I'm quite new to Linux. I'm using Linux Mint and I've just found a situation where I have a file which exists multiple times inside the tree/folders of a folder. I want to replace all occurrences of this file with a new version of it.
So instead of looking for that file once and again and replacing it with the new one, I wonder if there is any kind of search & replace command for files.
I've already searched for a similar question in stackoverflow, but I was only able to find commands to search & replace TEXT in files, not the file itself.
Can anyone please point me to the right direction?
Thank you.
you can always do it in parts, like:
Get a list of items matching your search.
Replace every match (using mv for example) with your file.
something like:
foreach dir ( `ls | egrep '^(i686\|amd64)\.'` )
mv yourfile $dir
end
I just installed Unite (with vundle), so that my .vimrc has 1 only new line:Plugin 'unite.vim'
Then I do this:
I open vi from my current dir (which has some nested subdirs & files)
I run :Unite file_rec
In the results-window I enter i
I continue writing some text (ex. pdf, but the problem occurs for any searched text)
the results change on the fly but they are always a subset of a full set of files retrieved by a normal: find . -iname '*pdf*'
(I know that the directories are not listed as candidate results, but I cannot see in the results, normal files (they are neither symlinks nor special-permission files). Moreover I refreshed the result/cache with <C-L>, but still the result remains partial.
Isn't this file_rec search, a Unite feature I should expect working out of the box ?
If not, which is the best option to overwrite the default behavior and make Unite search as a normal (find . -iname '*xxxxx*') ?
Thanks.
I found the reason. There is a builtin value for the max number of results (g:unite_source_rec_unit)
the documentation says:
The default value is 1000(windows environment), 2000(other)
[...]If you increase the value, |unite-source-file_rec| will be
faster but it will block Vim for a long time.
Note: This option does not work in
|unite-source-file_rec/async| source.
I just switched from Sublime Text to GVIM (on Windows). I am still debating whether I should continue ST or move completely to VIM. One feature that I desperately need (or miss) are
Ctrl+P to go to any file that I want in my list of folders.
Ctrl+Shift+f to find (and replace) any text in those list of folders.
I had added number of folders using Add Folders to Project feature in Sublime Text 3. It was really helpful. Now, I know that CtrlP plugin for VIM can do similar thing, but I can't figure out how to make it search the folders that I want, and not the root directory of current file.
I played around a bit with setting path in my vimrc file without much success.
Can you please help. If it is a repeated question, please excuse me.
Thanks.
AFAIK, ctrlp plugin only searches within one directory (and its descendants). Use the Unix features: make a directory with links to out-of-project directories you are interested in. This way, the association with out-of-project directories is not just something the editor knows about, but something recorded in the actual project.
Search and replace is a bit stickier thing. You want to work with all the files you are interested in, then repeat the replace command through all of them. For example, if you want to do the search for foo and replace with bar on all C files here and under,
:args **/*.c
:argdo %s/foo/bar/g
Ctrl+P to go to any file that I want in my list of folders.
The :find command can be used to "find" a file in the directories specified in the 'path' option:
set path+=/some/arbitrary/path
set path+=/another/one
:find *foo
I find these two mappings very handy:
nnoremap <key> :find * " search in every directory
" in 'path'
nnoremap <key> :find <C-R>=expand('%:p:h').'/**/*'<CR> " start from the directory
" of the current file
Ctrl+Shift+f to find (and replace) any text in those list of folders.
What amadan said above.
Good switch! So you’ve discovered CtrlP. It has extensive documentation built in. Use :h ctrlp to see the full vimdocs explaining the various options. It’ll explain some important settings for working dirs, which are pretty important for a good experience with it. Take for example some of the settings I use:
" The one you really care about...
" Set root to CWD. Another good option is 'r' for VCS mode.
" You should start vim in the root of your project tree
let g:ctrlp_working_path_mode = 0
" You _can_ switch dirs
let g:ctrlp_extensions = ['dir']
" Avoid big/unimportant project areas
set wildignore+=*/node_modules/*,*/build/*,*/components/*,*/_public/*,*/tmp/*,*/vendor/*
" Cache -- get used to pressing F5 on tree changes/additions
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
" Somewhat self-explanatory
let g:ctrlp_show_hidden = 1
let g:ctrlp_switch_buffer = 2
let g:ctrlp_max_depth = 6
let g:ctrlp_max_height = 50
" Open *h*orizontally and *j*ump to first win.
let g:ctrlp_open_multiple_files = 'hj'
" Use <C-d> to toggle
"let g:ctrlp_by_filename = 1
For further control of where to look for files outside your working tree, consult g:ctrlp_user_command. There is a Windows example using dir. You’d use that, but with your desired extra paths.
You might also want to add NerdTree, a nice complement to CtrlP. It is reminiscent of ST’s sidebar. Use its ? to get help. It has a menu that lets you quickly add files and dirs, maybe like you’re wanting out of “Add folders to project”.
For search-and-replace, look at ag.vim. I map it to <leader>g (meaning “grep”).
Those mentioned are some of my favorites, but you should explore the world of Vim plugins to decide which others are worth adopting. I recommend trying one at a time while you’re new, rather than a sometimes-opaque “distribution”. Tools to make plugin management easier are Vundle / Pathogen (choose one).
Eureka...!!!!!
After searching tirelessly for days (and sleepless nights), I found my answer (please read on).
First some foolosophy though
I was so keen not to give up on Vim. But this issue was just eating me from inside, and was disruptive in my work flow. I have many project folders in windows that I want vim to search through. Ctrl+p for some reason never really worked. I had some not-so-nice thoughts of giving up on Vim. and then I found this!
My Answer
This is a little different from what I expected. But the answer is Everything (by VoidTools). It allows to search from anywhere and gives results in a fraction of sec. It is by far the best filename search tool in Windows. It supports Regex. (though it is not text search tool). It has a command line interface called
es.exe
using Vim's FindEverything.vim plugin (FindEverything), I was able to search not only through my project folders, but pretty much anywhere. It returns the results in the vim buffer.
Thanks Y'all for your help. I know that not everyone may agree with this solution. But on Windows, this is by far the best solution, I found! Hopefully, it is useful for others why are in same boat!!!
I've just started using Android Studio (IntelliJ), and I now look for the feature to find the occurrence of a string in any of the files in my project. For example: I want to find all the files that contain the string ".getUuid()"
The search at the top right doesn't give me the correct results, and I don't think I can find this feature under Edit > Find.
Could anybody point me at the right direction?
TLDR: ⌃⇧F on MacOS will open "Find in path" dialog.
First of all, this IDEA has a nice "Find Usages" command. It can be found in the context menu, when the cursor is on some field, method, etc.
It's context-aware, and as far as I know, is the best way to find class, method or field usage.
Alternatively, you can use the
Edit > Find > Find in path…
dialog, which allows you to search the whole workspace.
Also in IDEA 13 there is an awesome "Search Everywhere" option, by default called by double Shift. It allows you to search in project, files, classes, settings, and so on.
Also you can search from Project Structure dialog with "Find in Path…". Just call it by right mouse button on concrete directory and the search will be scoped, only inside that directory and it's sub-directory.
Enjoy!
In Android Studio on a Windows, macOS or Linux based machine use shortcut Ctrl + Shift + F to search any string in whole project. It's easy to remember considering Ctrl + F is used to search in the current file. So just press the Shift as well.
Press Shift twice and a Search Everywhere dialog will appear.
Use Ctrl + Shift + F combination for Windows and Linux to search everywhere, it shows preview also.
Use Ctrl + F combination for Windows and Linux to search in current file.
Use Shift + Shift (Double Tap Shift) combination for Windows and Linux to search Project File of Project.
You can open the Find in Path dialog by pressing:
Ctrl + Shift + F
Android Studio 3.3 seems to have changed the shortcut to search for all references (find in path) on macOS.
In order to do that you should use Ctrl + Shift + F now (instead of Command + Shift + F as wrote on the previous answers):
UPDATE
To replace in path just use Ctrl + Shift + R.
Android Studio Version 4.0.1 on Mac combination is for me:
Shift + Control + F
And for all of us who use Eclipse keymaps the shortcut is Ctrl+H. Expect limited options compared to eclipse or you will be disappointed.
In Android Studio on a Windows or Linux based machine use shortcut Ctrl + Shift + R to search and replace any string in the whole project.
What you want to reach is that, I believe:
cmd + O for classes.
cmd + shift + O for files.
cmd + alt + O for symbols. "wonderful shortcut!"
Besides shift + cmd + f for find in path && double shift to search anywhere.
Play with those and you will know what satisfy your need.
use ctrl + shift + f on windows
Press SHIFT 2 times and you can search Every-where , both Class and Method() in the project.
Ctrl + N for finding only Class name.
Ctrl + E for Recent Files.
Use Ctrl + Alt + F combination in Ubuntu.
On a mac use shift + cmmd + f
To get rid of the screen press esc
I use IntelliJ IDEA
version: 2019.2.3 (Community Edition)
Build #IC-192.6817.14, built on September 24, 2019
Runtime version: 11.0.4+10-b304.69 x86_64
In Android 3.6 on a Mac if you want to export the results to a text file then do the following
Command+Shift+F then enter the text you want to search
Then on Bottom Right click on "Open In Find Window"
Then Right Click On Found Occurrences
Then Export To Text File
Once in text file you can find and replace to remove, sort lines etc... please see screenshots for assistance.
How do I (recursively) search all file contents in Windows 7? I am using the content:xxx command, in the Search settings box in Windows Explorer, to search xxx in this example. This does not work:
As an example of how this search is broken, I see an org.eclipse.wst.common.component file with text that I am searching for and Windows 7 is not returning it in the results. I assume it's only searching known text-based file types. How can I make it search all files? I need to find everything I am looking for.
P.S. If there is a DOS-based solution, I will also accept this. Maybe a batch file using dir /s /b and findstr could be constructed.
EDIT: Noted my need for a recursive search.
"user3245549" is right:
All of the above answers with "for loops" and nested bat files are mumbo jumbo. All you need is to just use "findstr" - example:
C:\temp> findstr /S /C:"/work" * | more <-- this will find the string "/work" in any file
or
C:\temp> findstr /S /C:"/work" "*.*" | more
or
C:\temp> findstr /S /C:"/work" * > results.txt
or
C:\temp> findstr /S /C:"/work" "*.*" > results.txt
NOTE: You can leave out the "double-quotes" around the asterisks - I just put those because the editor here on Stackoverflow was stripping out the asterisks on either side of the period.
NOTE ALSO: You still need the quotes around the "string text" for which you are searching, as far as I know.
If you are looking for a GUI-based solution where you don't have to remember the syntax, try out Notepad++. There is a Search menu which lets you search files in a directory (find in files), limit it to certain extensions (filter), and look in subfolders, and then you just click on the item in the list and it opens that file for edit.
Use the findstr command from a command prompt window.
/s give you a recursive search
/i ignores case
Here is my three file DOS solution, but I am still looking for a proper Windows 7 solution if anyone has one:
1. search.bat
#ECHO off
FOR /r %%a IN (*.*) DO CALL process.bat %%a
Searches all files recursively, and runs process.bat on each one.
2. process.bat
#ECHO Off
ECHO "%1" >> output.txt
TYPE "%1" | FINDSTR /i "search_string_here" >> output.txt
Prints out the name of each file, in quotes because some files will break the batch file code without, then finds the search string, search_string_here, and prints out the entire line that the search string is found in.
3. output.txt (sample output)
Contains the output, formatted as follows, searching search_string_here in my project_name Java project stored in D:\project_name\, displaying all files searched as well as results if there are some:
"D:\project_name\.classpath"
"D:\project_name\.project"
<name>search_string_here</name>
"D:\project_name\content_search_all_files.bat"
"D:\project_name\output.txt"
<name>search_string_here</name>
"D:\project_name\pom.xml"
...
Above you can see that search_string_here was found, full line being <name>search_string_here</name>, in D:\project_name\.project file... among other results.
Again, I am still looking for a proper Windows 7 solution if anyone has one.
Warning: "Line is too long" Errors; FINDSTR may be buggy:
Apparently, FINDSTR < grep, as if you didn't know. Here's an article that dives into the error in FINDSTR that are do not reproduce when the same input is used in a different file:
Obviously, “line is too long” is a catch-all message for a number of
different errors. FINDSTR has some issues. Some time ago, I said that
FINDSTR was marginally useful. After today, I’d say it’s even less
useful than I thought it was then.
- http://blog.mischel.com/2008/10/14/copying-large-files-on-windows/
This can be done through the command prompt, though the syntax is quite verbose
for /r %a in (\*.*) do find "search_text" %a
This now works in Windows 7 (extra dot removed)
If you're looking for a file or folder located in a common folder (such as Documents or Pictures), you can often find it fastest by using the Search box at the top of the folder window. For more information, see Use the Search box.Here.
If you're looking for a program, a website in your browser history, or a file that you've stored anywhere in your personal folder, you can use the Search box at the bottom of the Start menu. For more information, see Find a file or folder.Here.
If you're looking for several related files, such as all the files from a particular month, or all the documents that you have written, you can use the headings above the file list to filter, stack, or group your files. Organizing your files in one of these ways makes them easier to locate and select. For more information, see Use file list headings.Here
When you need to build a search with multiple filters, or when you're looking for files from several folders at once, create your search in the Search folder. When you are done, you can save the search criteria, and use it in the future to find the same set of files again with a single click. For more information, see Create an advanced search in the Search folder.Here