Search code examples
firefoxfirefox-addonvimperator

How to trigger a Vimperator command after manually openning a new tab?


I've been using Vimperator for some time and I'm really happy with it but there is a break in my workflow which bothers me:

Sometimes I open a new tab "manually" i.e. using Ctrl+t or even by clicking on the + sign next to the last tab. I know I can open a new tab with :tabopen and I created a convenient mapping for that but sometimes I just don't use it.

My problem is the following: I set set gui=nonavigation in my .vimperatorrc so when I open a tab "manually" if I forget to type o to trigger the command line with the open command and instead directly type the url I get unexpected results since the keys I type as a url are simply considered as vimperator input.

So my question is: Is it possible to trigger a vimperator command after using Ctrl+t or clicking the + sign? The idea would be to automatically type o after those two events so I'm directly in the command line with the open command to complete.


Solution

  • Pentadactyl: General Solution

    This solution works in Pentadactyl (which I'll include here since Pentadactyl falls under the Vimperator tag on SO).

    It should work on Vimperator as well, but doesn't (at least on my version), since Vimperator is hopelessly buggy. It should be possible to work around the bugs, but I didn't find a way when I tried it.

    Anyway, the right way to do this is with an autocommand, which will execute whenever an about:newtab url is loaded.

    • begin :open command when loading a new tab page:

      autocmd PageLoadPre about:newtab normal o
      
    • begin :open command when loading or changing to a new tab page:

      autocmd LocationChange about:newtab normal o