Sublime Forum

How to search a variable in project scope?

#1

Hi

I’m using Sublime Text and it is really great.

I have a C file project in Sublime Text. The project include many C flies (and header files).

When I what to search a variable in scope file I use the command - Ctrl+F.

Can you please tell me what is the command for search variable in project scope (in all the files of the project)?

Thank you very much

Michael

0 Likes

#2

I use these key-binds… Preferences > Key Bindings…

	// Display all open files in a quick-access menu
	{ "keys": ["f1"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },

	// Search in the current file for the word currently under the cursor and repeat search each keypress
	{ "keys": ["f2"], "command": "find_under" },

	// Default Key: Find next instance of word
	{ "keys": ["f3"], "command": "find_next" },

	// Show all CONSTants, Variables, ENUMeration, Namespaces, Systems / Classes / Libraries in the project
	// { "keys": ["f4"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
	{ "keys": ["f4"], "command": "goto_symbol_in_project" },

	// Find unique word instances in a file
	{ "keys": ["f5"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"} },

	// Goto a line number in the current file
	{ "keys": ["f6"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },


	{ "keys": ["f7"], "command": "quick_goto_function" },
    { "keys": ["f8"], "command": "quick_goto_variable" },


	// Show all available snippets along with options to create / manage them
	{ "keys": ["f9"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Snippet: " } },

	// Select the current Project or Workspace
	{ "keys": ["f10"], "command": "prompt_select_workspace" },

	// Command Pallette - Uses last keyword to show last pallette... empty text to show all options..
	{ "keys": ["f11"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": " " } },

	// Package control - Install New / Disable / Remove / Search / Info and much more..
	{ "keys": ["f12"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Package Control: " } },

Take a look at F4 through F7 or so… Also using different symbols can mean different things such as @, etc… to search, simply type in the box that opens when you press the keys…

If you decide to use the entire listing: F1 shows open files, F2 searches for the word under cursor and can find next, etc… F3 is find-next exclusively and will open the basic find panel ( I am looking for a way to alter it so F3 can open the advanced search but still find next - hopefully it is possible or I’ll need to write an addon ), F4 shows project symbols, F5 and F6 are also project or file variables or other data such as function definitions, etc… not exactly sure haven’t really used them since installing CodeMap and writing a new addon for it ( XCodeMapper which improves the output and provides mappings to many languages: https://bitbucket.org/Acecool/acecooldev_sublimetext3 )… F7 and F8 are similar… they show function definitions, etc… F9 is for snippets, F10 for changing projects, F11 and F12 are for the command palette… and Package control…

I may end up rebinding a few of these to be more useful… but seeing as these may be what you’re after - here you go…

0 Likes

#3

To search through more than just the current file, the command you probably want is Find > Find in Files... or it’s associated key binding (see that menu item for the default on your system).

The list of files searched is the Where field, which defaults to all open files and all open folders, but you can use the button to the right of it to add inclusions and exclusions, such as searching all files except txt files or whatnot.

0 Likes