+3
posted by Michael Bond , updated 1 year ago , 5
When doing an incremental find, the previous search should remain. Currently when you click out of the find search box and then use the hot-key to go back to it, the contents of the box are removed. 

Instead the contents should be highlighted (so when you begin typing it removes the old), but also allow for continued incremental searching on the previous search term.

This behavior would be more in-line with what Emacs and Textmate do. 

Perhaps it could be an user-configurable option if making it default doesn't make sense. 
Vote
The find panel does work this way, by the above description, it sounds like it's exactly what you're after.

The incremental find panel has slightly different semantics that require it to start empty. If it contained the last searched for term, then as soon as it's displayed, it would be required to jump to the first match for that term - this would be a jarring user experience.
Find doesn't work like incremental at all though. If the find panel is open hitting "cmd+f" again doesn't take you to the next occurrence of the search term.

If i could do something like this:
{ "keys": ["ctrl+s"], "command": "show_panel", "args": {"panel": "find"} },
{ "keys": ["ctrl+s"], "command": "find_next" },

find would work for me. (I've used emacs and textmate for way too many years to change my key binding muscle memory ;-) 

The above doesn't seem to work though. 

FTR, this gets pretty close.  I haven't used it in much anger yet, but it seems to get pretty close to emacs behavior.


    { "keys": ["ctrl+s"], "command": "show_panel", 

        "args": {"panel": "find", "reverse":false} },

    { "keys": ["ctrl+r"], "command": "show_panel", 

        "args": {"panel": "find", "reverse":true} },

    { "keys": ["ctrl+s"], "command": "find_next",

        "context":

        [

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["ctrl+r"], "command": "find_prev",

        "context":

        [

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

Actually maybe more like this.


Emacs stops the incremental search any time that anything other than ctrl-s or ctrl-r is pressed.  The sublime equivalent would be to hide the panel.  In Emacs, I'm typically pressing down arrow or up arrow to exit a search initiated that way because that's just how my mind happens to work.  Unfortunately, I can't quite get there with sublime.  It will let me override right and left arrow, ctrl-a and ctrl-e to hide the panel, but it still wants to cycle through existing search terms in the panel search box when up and down are pressed instead of hiding the panel.  In any case, here it is.


    // Override sublemacs:  use find panel rather than incremental find, as

    // incremental search panel doesn't retain last search value

   

    { "keys": ["ctrl+s"], "command": "show_panel", 

        "args": {"panel": "find", "reverse":false} },

    { "keys": ["ctrl+r"], "command": "show_panel", 

        "args": {"panel": "find", "reverse":true} },

    { "keys": ["ctrl+s"], "command": "find_next",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["ctrl+r"], "command": "find_prev",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["enter"], "command": "hide_panel",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["ctrl+e"], "command": "hide_panel",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["ctrl+a"], "command": "hide_panel",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["right"], "command": "hide_panel",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    { "keys": ["left"], "command": "hide_panel",

        "context":

        [

            {"key": "panel", "operand": "find"},

            { "key": "panel_visible", "operator": "equal", "operand": true }

        ]

    },

    // down and up unfortunately can't be caught in this context, so these

    // don't work

    // 

    // { "keys": ["down"], "command": "hide_panel",

    //    "context":

    //    [

    //        {"key": "panel", "operand": "find"},

    //        { "key": "panel_visible", "operator": "equal", "operand": true }

    //    ]

    // },

    // { "keys": ["up"], "command": "hide_panel",

    //    "context":

    //    [

    //        {"key": "panel", "operand": "find"},

    //        { "key": "panel_visible", "operator": "equal", "operand": true }

    //    ]

    // },

Hey Chris,


I modified the handling of the incremental search box in Sublemacs so that as soon as the search bar loses the focus the search is aborted, which makes the  behaviour more emacs like.


Martin