[Solved] Search indexing of a local source folder..

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Hultan
Level 3
Level 3
Posts: 178
Joined: Mon Aug 27, 2018 10:58 am

[Solved] Search indexing of a local source folder..

Post by Hultan »

I have a pretty large folder containing all the source code for my personal projects. I often want to search that folder for, for example, variable names or function names, to find specific parts of code. Basically I want to google search my code...

I was thinking of doing this myself as another one of my coding projects, but I want to at least see if there are already existing products like this.

Some features that I want:

* Parse different languages (Go, Vala, Python, ...)
* Ability to exclude keywords from those languages
* Exclude certain type of files, non-text files, asset files etc
* Preferably an easy to use GUI for searching (CLI would work though, I could write the GUI on top of the CLI)
* Tooltip showing a few lines of code (containing the match) when hovering the search hits, or something similar...
* Advanced search : wildcards, [word] NEAR [word], etc
* ...
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
spamegg
Level 14
Level 14
Posts: 5024
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Search indexing of a local source folder..

Post by spamegg »

You can use a modern IDE to do all that "global searching" type of stuff. For example JetBrains IDEs such as IntelliJ or PyCharm, and Visual Studio Code have a "global search" option with Ctrl+Shift+F (or some variant). Here is a typical example:
vscode.png
You can use grep on the Terminal for pretty much everything you listed. Learning grep properly is an extremely good investment in the long term, it pays off quite well!

You can also use the GUI version vizigrep by installing apt install vizigrep (the colors look crap on my theme, but don't mind that):
vizigrep.jpg
Hultan
Level 3
Level 3
Posts: 178
Joined: Mon Aug 27, 2018 10:58 am

Re: Search indexing of a local source folder..

Post by Hultan »

Well, CTRL+SHIFT+F search in the current project only, and I use that all the time in GoLand. What I am looking for is a way to search all projects in my entire code library. For example, if I know that I have a solution to a certain problem in another project, but I don't remember which project.

And the vizigrep solution, that searches the folder every search correct? That might not be a problem, but I was thinking of an indexing solution. I will look into vizigrep though, maybe that is fast enough...
User avatar
spamegg
Level 14
Level 14
Posts: 5024
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: Search indexing of a local source folder..

Post by spamegg »

You can open your "entire code library" as the "current project" but I guess that might be too slow. Some IDEs do build indexes though, you'd have to look into that more.

There are some interesting ideas for how to manually build indexes here: https://stackoverflow.com/questions/773 ... -indexable

Maybe look into Ack, it says it's specifically designed for large source bases: https://beyondgrep.com/ It's in the repositories: apt install ack
Rooo
Level 2
Level 2
Posts: 52
Joined: Sun Nov 21, 2021 9:00 am

Re: Search indexing of a local source folder..

Post by Rooo »

^^^ will be trying those later,thanks :)


being a noob I love this :)


"FSearch is a fast file search utility, inspired by Everything Search Engine. It's written in C and based on GTK3."

https://github.com/cboxdoerfer/fsearch
Attachments
Fsearch.png
Forum Pest ...

"Easy tips for Linux Mint and Ubuntu, both for beginners and for advanced users" https://easylinuxtipsproject.blogspot.com/p/1.html
Hultan
Level 3
Level 3
Posts: 178
Joined: Mon Aug 27, 2018 10:58 am

Re: Search indexing of a local source folder..

Post by Hultan »

A lot of interesting projects you link to...I especially like codesearch, since it was written in Go :-) I'll have to look into that...

I tried to open my entire code folder in Goland, and it seems to do the job, and it is fairly quick. A little bit annoying though that you'll have to open the entire folder in another Goland instance, but I guess that is doable and fairly quick the second time. Maybe there is a way to search the entire index even if you have only one subfolder open, but right now I don't know if that is possible. It certainly is indexing the entire folder, so maybe? I might have to contact JetBrains support and ask about this...downside though, I don't know how it handles searching in other languages, like my Vala projects, or Python projects...anyway, I'll have to look into that as well.

Fsearch is also very close to what I want, except maybe I would like some preview of each search hit (in a tooltip, or a readonly preview to the right, or...).

Anyway, thanks for all you suggestions...
Locked

Return to “Beginner Questions”