Sublime Forum

How to find all in current file?

#1

I think find all is very useful. The search result list is very helpful.

But I don’t how to do a find all in current file. I am not meaning to loop in current file, but list the search results.
Now I can only do this by typing current file’s filename in “where” bar, and do a find all. But it require really too much types. Is there a shortcut for current file?

0 Likes

#2

How are you invoking the find panel? Are you using SHIFT+SUPER+F? If so, that’s Find in Files. Try just SUPER+F, which is simply Find and will work in the current view. Or you can use the Find menu.

0 Likes

#3

I think he’s looking to have a list created like Find in Files does. When you do a find all using the CTRL-F find, it just highlights them. I can see how a list would be beneficial in a very large file, but I don’t know that it’s possible out of the box. The only thing I can think of off the top of my head is to do a find in files, and change the option to “all open files” and only have the one file open. Lame solution I know, but if you MUST have a list, that’s one way. :smile:

0 Likes

#4

Oh, I see. I use ack on the command line for searching through multiple files and had not yet encountered the find all list. I can see how that might be useful.

Sorry for the misunderstanding/noise.

0 Likes

#5

+1

This is a very nice feature that does not force you to go through each instance in the current file. Is there an easy way to do a plugin to accomplish this?

0 Likes

#6

Just wanted to say that I’ve been using the Find in Files feature in ST2 and I like it. It’s nice to be able to see a few lines of context around the hits (that’s what I miss in ack) and being able to double click to go to the file and line is very nice. Quite speedy, too. Very impressive.

0 Likes

#7

I like this feature as well, but would like a way to search the current file. I think this should be possible with either a binding or a plugin.

for the current hotkey, it is setup as:
{ “keys”: “ctrl+shift+f”], “command”: “show_panel”, “args”: {“panel”: “find_in_files”} },

when the “find_in_files” panel comes up, is there a way I can send as an argument the value for “Where” and send it the current file name? this would accomplish what I am looking for but am not sure how to do this. The “Find” value is already loaded with the currently selected word.

0 Likes

#8

I would like this too, but as this was asked 8 years ago and not answered I guess I will not be in luck. I am considering moving to sublimetext from jedit and one of the features I love in jedit is just to Alt+. on a word and get a hypersearch page showing all occurrences of this in the current file.

0 Likes

#9

If you have the Chain of Command package installed from Package Control, you can set up a key binding for your task.

{
	"keys": ["alt+."],
	"command": "chain",
	"args": {
		"commands": [
			["slurp_find_string"],
			["show_panel", {
				"panel": "find_in_files",
				"where": "<current file>",
			}],
			["find_all"]
		]
	}
}

Once you select the word (or even place the cursor over the word) you want to search in the current file, press the said binding, it will show you all occurrences of the selected word.
Edit : Credits to @OdatNurd for the find_all command :slight_smile:

0 Likes

#10

If you add find_all as a third command in the chain, it will execute the find immediately as a part of the key binding.

0 Likes

#11

Updated my answer with credits to you :slight_smile:

0 Likes

#12

Wow, thanks, that is perfect. I’d never of worked that out for myself.

0 Likes

#13

this is very useful. thanks a lot.
but there is a problem. it selects the word under cursor and then performs search on it.

i want to open up the panel and search whatever i want and after i press enter the chain command can run.

how can i achieve that?

just like default ctrl+f, but with find_all results from current file, in a separate window.

thanks in advance.

0 Likes

#14

thank you for your reply with us, this is really helpful for me

0 Likes