disable Vimperator temporarily

后端 未结 5 601
轮回少年
轮回少年 2021-01-31 02:52

How can I disable Vimperator temporarily? For example, I\'d like to disable Vimperator temporarily when I am using a web email app. Is there a command for it?

5条回答
  •  春和景丽
    2021-01-31 02:57

    I am guessing you already know about Shift-Esc to temporarily disable vimperator. So I wrote how to disable vimperator based on your current location.

    First, the solution:

    autocmd LocationChange .*                             js modes.passAllKeys = false
    autocmd LocationChange mail\\.google\\.com            js modes.passAllKeys = true
    autocmd LocationChange www\\.google\\.com/calendar    js modes.passAllKeys = true
    autocmd LocationChange www\\.google\\.com/reader      js modes.passAllKeys = true
    autocmd LocationChange mail\\.google\\.com/tasks      js modes.passAllKeys = false
    

    This filters gMail, gCalendar, gReader, but not gTask.

    The solution I gave is cascading approach where you define all websites to enable vimperator, then it selectively disables for each website. Thus, even though gTask uses the same parent site as gmail, it has vimperator enabled.

    Now the explanation:

    These commands go in your .vimperatorrc in the home directory. You can change the location of the .vimperatorrc by

    source! *directory*
    

    in .vimperatorrc file, but the default location is .vimperatorrc file in your home directory. (%userprofile% in Windows)

    The alternative solution:

    autocmd LocationChange .* js modes.passAllKeys = /mail\.google\.com/.test(buffer.URL)
    

    *Notice the backslash to escape the dot.

    The problem with this approach is that only the latest line of command with autocmd will take work. Meaning the last autocmd command overwrites the first. So you would end up resulting to boolean operation on the command, like this:

    autocmd LocationChange .* js modes.passAllKeys = /(mail\.google\.com|google\.com\/reader)/.test(buffer.URL)
    

    As you can see this can get complicated when you have many websites you want to filter out.

    The documentation: http://vimperator.sourceforge.net/help/vimperator/autocommands.xhtml
    Source of the solution: http://code.google.com/p/vimperator-labs/issues/detail?id=406

提交回复
热议问题