ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Find​In​Files-addon

by kaste ST4

Add-on for Sublime Text's Find-In-Files-feature

Labels find, add-on

Details

Installs

  • Total 120
  • Win 61
  • Mac 40
  • Linux 19
May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14
Windows 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 2 0 1 0 1 0 0 0 0 0 0 2 2 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0
Mac 0 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 2 1 0 0 0 1 0 0 0 0 0 1 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Find in Files add-on for Sublime Text

This plugin enhances the Find in Files feature of Sublime Text. It attaches to the result buffer automatically and adds the following features:

  1. Make all lines in a find-in-files result buffer double-clickable. Bind <enter> to do the same thing, namely go to that line. (But also set the column, well … just set the complete selection.)

  2. Also, register the filenames as local symbols for quick navigation and outlines. Use ctrl|super+r (Sublime's default) to open the symbols panel, or however you use that in your daily routine. (E.g. I have a global shortcut to jump from symbol to symbol.)

  3. Bind , and . to go to the previous or next match staying in the result buffer. Just move the cursor (“navigate”) around.

    But you can also bind fif_addon_prev_match and fif_addon_next_match on your own.

  4. Bind ctrl+enter to open a preview, side-by-side. The preview will update when you navigate around. Both, enter and ctrl+enter will close the preview. As there is no side-by-side to a results panel, this will only work for result buffers. Also, if you already use the newish “find_in_files_side_by_side” setting, there is no real difference as you already opted-in to always use a side-by-side view. (Hint: Turn find_in_files_side_by_side off and use the preview feature here.)

  5. Bind + and - to change the number of context lines. For ease of use, hit - repeatedly as a toggle between no context and your default, or if your default is no context between that and some context.

  6. Bind f5 to refresh the view, t.i. redo the last search. Hm, 🤔, maybe we can change that and redo the search the cursor is currently in. But for now it is the last search in the buffer.

  7. Bind alt+c[3] to toggle case sensitivity, alt-w to toggle the whole word flag and redo the search immediately.

  8. Bind alt+r to toggle regex mode. The pattern will be escaped/unescaped and the panel will open to edit the pattern further.

  9. If you reuse the result buffer (and it is a tab, not the panel thing at the bottom of the window), the tab moves with you so that closing the tab (aka ctrl+w) brings you to the view where you initiated the search.

  10. Add the search summary (e.g. “2 matches across 2 files”) to the search header line (“Searching 9 files for …”)

  11. Re-bind ctrl+shift+f to immediately do the search if you have exactly one selection. Exclude untitled buffers in that case. (You can turn this off by setting "leave_my_keys_alone.FindInFiles-addon": true in the user preferences.) Sets “whole_word” if you've selected a whole word, unsets it if that's not the case. Also normalizes case_sensitive and regex to false.

[1] On Mac, the standard super+alt modifier is used. Generally, these should be just the standard bindings, you already use in the Find-panel to toggle the switches.

1

Registering “local symbols” populates the Goto panel. I use it in combination with the InlineOutline plugin, which looks like so:

Outline View using InlineOutline

2

I personally like it when escape closes the results view. You can add that to your own key bindings. E.g.

{
        "keys": ["escape"],
        "command": "fif_addon_goto_abort_search",
        "context": [
            { "key": "selector", "operand": "text.find-in-files" },
            // negate all default escape contexts, even if they're not likely to ever match
            // adjust to your liking
            { "key": "auto_complete_visible", "operator": "not_equal" },
            { "key": "has_next_field", "operator": "not_equal" },
            { "key": "has_prev_field", "operator": "not_equal" },
            { "key": "num_selections", "operator": "equal", "operand": 1 },
            { "key": "overlay_visible", "operator": "not_equal" },
            { "key": "panel_has_focus", "operator": "not_equal" },
            { "key": "panel_visible", "operator": "not_equal" },
            { "key": "popup_visible", "operator": "not_equal" },
        ]
    }

The command fif_addon_goto_abort_search basically is like close, just that it also closes the preview if any is open.