At some point I had either found or written a command to “Find in files” at the current directory. I can’t seem to get this to work again. Help
Find in Files at the current directory
Perhaps something like this? Uses the built in Find in Files, just auto fills the “Where” with the current directory.
[code]import sublime
import sublime_plugin
import os
class FindInCurrentFolderCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
window = view.window()
current_dir = os.path.dirname(view.file_name())
window.run_command(“find_in_folder”, {“dirs”: [current_dir]})[/code]
This is great @skuroda. Thank you very much!
For additonal copy-paste goodness:
// Find in Files at Current Folder
{ "command": "find_in_current_folder", "caption": "Find in Files: At Current Folder" },
Incidentally, do you have any insight on this: viewtopic.php?f=2&t=9271#p37212 ?
Alex
Sorry, I don’t have any idea of how to fill in the “Find” field. Another possible route is to see if they can add a context option to SublimeTODO.
Here’s a slight modification to work with sublime_text_3:
import sublime, sublime_plugin import os class FindInCurrentFolderCommand(sublime_plugin.TextCommand): def run(self, edit): view = self.view window = view.window() current_dir = os.path.dirname(view.file_name()) window.run_command("show_panel", {"panel": "find_in_files", "where": current_dir})
You can bind a key to it thus:
{ "keys": ["ctrl+shift+f"], "command": "find_in_current_folder"}
FWIW, this is a very old thread you brought up.
I currently use: https://packagecontrol.io/packages/Find%2B%2B
It can find files in the current folder and much more.
Thanks for the pointer. When I was looking for this feature, this is the only thread I could find – but I’ll try this package out.
-Arun
With the latest beta of ST3 you can just add this keybinding:
{
"keys": ["ctrl+shift+g"],
"command": "find_in_folder",
"args": {"dirs": ["."] }
},
Find in Files automatic fill in Where field