Keyboard file switching plugin available

2009-03-30
2012-11-14
  • Hi,
      I've put together a little plugin that switches between files, by entering any part of the filename.  It's handy if you don't like taking your hands off the keyboard to switch files.

    This is my first go at a plugin, and also pretty much my first bit of real C++, and my first bit of win32 api C++ at that, so apologies if it's a bit sketchy, but it does seem to work fine. 

    This is 0.1, I've a few ideas for improvements -
    * remember what was typed in each buffer, so that switching between two or three common files is easier (I need to get the FILECLOSED message for this to tidy itself up properly, and I don't seem to get it - anyone any ideas?)

    * allow some options to include the path in the search
    * save the window size (don't quite understand what resizes it back when it's reshown yet!)

    Let me know what you think - feedback welcome!  I'll put the code up when I've tidied it up a bit and got the above stuff in.

    http://www.brotherstone.co.uk/npp/FileSwitcher.zip

    Many many thanks for a great editor, our team of 6 use it day in day out.

    Cheers,
    Dave.

     
    • 1 is kind of fixed (with a workaround) in 0.2, which is available now, as it will remember the window position, so once you've sized the window, it will stay like that, including between loads.  2 is also fixed.

      Thanks to cocinerox - d'oh! I hadn't removed the switch to next document shortcut, which obviously took precedence.  I'm going to have a play with this, and see if I can get an interface that feels nice...

      Thanks again,
      Dave.

       
    • Thell Fowler
      Thell Fowler
      2009-03-31

      Dave,

      As someone who always has multiple tabs, and views open this may come in handier than ctrl-tab/ctrl-shift-tab, and like you, I like to keep my fingers on the keyboard.  Perhps, adding the ability to use ctrl-tab/ctrl-shift-tab to move between the open files?  Then it would surely be a replacement for the built-in switcher.

      Thanks, and nice job!
      almostautomated

       
    • Notepad++ does this already, and in quite a nice way - give it a go!  Unless you meant something else?

      Dave.

       
    • Thell Fowler
      Thell Fowler
      2009-03-31

      Yes, it does do it, and, as you say, in a nice way...  I was thinking that perhaps having both concepts merged into one would be nice since they both serve the same purpose.

       
    • Sorry i misread your post, what ideas have you got for combining them? I can obviously make tab and shift tab move the listbox selection, but not sure thats more intuitive than just up and down.
      If you can explain what you meant i'll certainly have a go.
      Thanks again,
      Dave

       
    • Thell Fowler
      Thell Fowler
      2009-04-01

      Dave,

      I was just thinking that your keyboard switching combined with the existing switching would allow the ctrl-tab/ctrl-shift-tab to open the file switching dialog, continual ctrl-tab/ctrl-shift-tab would cause the normal behavior of cycling through the entries, and if someone started typing the file name it would filter ( like it does ).

      I like the plugin, yet after using so many apps that use ctrl-tab/ctrl-shift-tab I keep finding myself using that shortcut then remembering that I now have _another_ shortcut that will allow me to get where I want to go even faster, yet since my fingers are already ctrl-tabbing I just stay there and continue to cycle through.

      Say I have twenty open files, and I need to switch from appserv01-operlog to webserv01-syslog; using a session I know the files will always open in a known order, and the built-in quick switch keeps the files in tab order, so if I'm close to the tab I won't need many ctrl-tabs to move, yet if I'm quite a ways away I may need 19 ctrl-tabs.  I don't really know until I start ctrl-tabbing though; if your plugin had the same functionality as the built-in switcher except with the addition of being able to start typing a file name, then as soon as it was realized how far the tab was, typing of 'w' would immediately drop me down to the just a few choices...  Granted, hitting the file switcher shortcut isn't hard at all, but not having to hit it would be better. :P

      almostautomated

       
    • A-ha, I see what you mean now. I like your thinking.

      I think this is certainly possible, although there are a couple of small obstacles.  One should be quite easy to overcome, in that N++ doesn't support (as far as I can tell) a plugin handling Ctrl+Tab - I tried, and it just keeps it for itself, which is fair enough.  So, we'd need to put a (hopefully) small change into N++ to allow support for that.

      The second issue is more of a usability issue.  Say you started Ctrl-tabbing, and realised you were 19 tabs away from where you wanted to be, you'd have to keep your finger on Ctrl whilst typing the 'w', which might be ok for one letter, but might get awkward for more than one (especially if it's 'g', 'h' or 't' you're after).  Obviously when you let go of ctrl, the file is switched and the dialog disappears. The alternative is to have a key that you can press to switch to key entry mode, so whilst you're ctrl-tabbing, if you hit say 'q' instead of tab, you'd be able to type  to search, but that's one extra key press.

      Incidentally, I'm just putting the finishing touches to 0.2, which does all the things on first post, I'll hopefully put it up with the source tonight.

      Any thoughts?

      Dave.

       
      • Thell Fowler
        Thell Fowler
        2009-04-02

        You're right Dave, I hadn't considered that issue...  That's one to think about for a while. :P

        Two other things:
        1)  It would be nice is if the pop-up would resize to fit the content, for same named files in different directories.
        2)  Both capital and lower-case should be valid input.

        I'm getting quite a bit of usage out of it.

        Thanks,
        almostautomated

         
      • cocinerox
        cocinerox
        2009-04-02

        Hi! With the shortcut mapper I managed to remove the Ctrl+Tab shortcut from "Switch to next document" and assigned it to your plugin's command. By the way, nice work! cocinerox