2

Is it possible to let Visual Studio Code to index file content? Right now in my C code project when I want to find some declarations or calls or just search for string in content of files in the project I have to wait a long time to get results and one wrong click and I have to repeat the search again and wait again.

Would be great to know if it is possible to index all project files (with exclude rules) and saved search results to avoid research the same things.

Plus how to handle the file changes (reindex). Any help for this? Thanks.

music2myear
  • 40,472
  • 44
  • 86
  • 127
Manium
  • 21
  • 1
  • 3

2 Answers2

1

Visual Studio Code can have index a folder, just as a table of contents of all exportable variables and functions within its files, by including an index.js file inside the ComponentOne directory.

The Indexify extension simplifies turning this on:

Index files (index.js/index.ts) act as a directory's table of contents. They are great for tracking exportable functions and variables. They allow you to easily import them into your codebase without having to dig them up from buried sub-directories.

The only problem is manually keeping track of all your exports and updating index files. That's where Indexify comes in!

Indexify adds options to your context menu to auto-generate index files on the fly. All you have to do is right-click on any directory in the explorer and select either a shallow index (indexes only the root of the selected directory) or a deep index (indexes all nested directories)

You may read a more detailed description of the extension in Effortless Index Files with VS Code.

For brute textual search, if VS Code is too slow, you could search for a third-party utility.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Yes, thanks, I have already seen this extension before. But it is limited to the JavaScript/TypeScript, what is the point of it for my case? I am using the C code like i described above. I have added and bolded this in the question right now. – Manium Apr 22 '22 at 13:59
  • There is a lack of information about this `index.js` file. Although `Indexify` only does JS/TS, this file might not be limited to it. – harrymc Apr 22 '22 at 14:03
  • Indexify supports *.js, *.jsx, *.ts, *.tsx file formats + exports. How will it support the *.c and *.h? There is no information about it in this extension. – Manium Apr 23 '22 at 10:10
0

Your VS Code application itself might be slow, check for that, restart and try again.

If you are working on a host with remote connection, then VS code will be slow some times because of network latency or if any extensions are being installed on remote host while the search task is going on then also search functionality will be slower.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 25 '23 at 01:53