Sublime Forum

Find in Files automatic fill in Where field

#1

Hi,

I’m used to using Notepad++ and am switching over to ST and loving it. What I’m missing is the ability for ST to automatically fill in the path of the currently viewed file in the Where field. I most often would like to search the parent folder of the currently viewed file and having the path filled in automatically allows me to quickly adjust the path to the parent folder and quickly execute Find in Files for a certain text.

Is this possible in ST 2?

0 Likes

#2

FWIK, must be done with a plugin.
Something like (not tested):

[code]import sublime, sublime_plugin
import os.path

class FindCurrentDirectoryCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command(“find_in_folder”, {“dirs”: [os.path.split(self.window.active_view().file_name())[0]]})[/code]
Adapt for your use (like getting the parent folder of the current file) and bind it to a keymap. Voilà!

0 Likes

#3

If you switched to ST3 see Find in Files at the current directory

0 Likes