configure ctrl-i external editor call to work around certain JS editors
Certain JS editors, like the one at stack overflow (called pagedown), use ctrl-i for there own purpose. Vimperator needs a way to work around this.
There's probably some way around it but it's super tricky, probably. Someone will need to investigate.
This also applies to the new GitHub editor which will insert __. How about an additional, secondary keybinding that is unlikely to be used by sites?
Heh, interesting. This isn't an issue on OSX because the shortcut is still <C-i> for the editor but github uses <Command-i> for the markdown insertion.
I'm not against adding another key combo, the question is whether something is available? I wouldn't want to just keep adding combos in insert mode.
You can also create your own mapping for it:
inoremap <C-g> <C-i>
While there is no guarantee, I assume it is rare that both <C-i> and <C-S-i> are bound in a text field.
inoremap <C-S-i> <C-i>
And to be consistent:
inoremap <C-S-t> <C-t>
At least these are easy to remember and might have a higher chance to work compared to a second binding like <C-g>.
Using inoremap <C-S-i> <C-i> is not a complete work around, as using the remapped shortcut to open the external editor interfere with other shortcuts, e.g.:
- click on text field
- press
<C-S-i>: external editor appears - give focus back to the browser, unfocus the text field with
<Esc>and press<:>to open the command line: nothing happens - close the external editor: now Vimperator is in command line mode
Note: using @blueyed editor configuration with an additional shortcut to work around those sites that use <C-i> does work fine however.
@benoit-pierre
So the key is to use another mapping (<F4> in my case), right? (https://github.com/blueyed/dotfiles/blob/f4634c1371e3e7553509e0632fe65a6ddd6758ff/vimperatorrc#L309)
(I mean: you do not have to use the whole advanced function.) (I might have misunderstood that part)
In my case, <C-S-i> interferes with closing the dev tools. Instead of closing them, I sometimes end up editing a CSS property in gVim externally.
A second default shortcut for sites that intercept <C-i> should be:
- cross-platform,
- unused,
- convenient (function keys are far away from the home row and might require pressing the
Fnkey), - easy to remember.
How about <C-S-e for “edit” or “external”?
My problem is not about the choice of alternate shortcut, but how mapping this alternate shortcut using inoremap <C-S-i> <C-i> result in a different behavior when using it. Using
js mappings.addUserMap([modes.INSERT], ["<C-S-i>"], "Launch the external editor.", function() { editor.editFieldExternally(); })
to setup the alternate mapping does however work fine.
I've found that the following Greasemonkey script, which I based on this, successfully undoes site-specific bindings of C-i, allowing Vimperator's C-i to work as normal. Add @include lines to taste. Also, there may be a way to implement this in one's .vimperatorrc rather than Greasemonkey.
// ==UserScript==
// @name Disable site keyboard shortcuts
// @description Stop websites from hijacking keyboard shortcuts
// @version 1
//
// @run-at document-start
// @include https://github.com/*
// @include https://www.gamefaqs.com/boards/*
// @include /^https://[a-z0-9]+.stackexchange.com/
// @grant none
// ==/UserScript==
keycodes = [73]; // Keycode for 'i'
(window.opera ? document.body : document).addEventListener('keydown',
function(e)
{if (keycodes.indexOf(e.keyCode) != -1 && e.ctrlKey)
{e.cancelBubble = true;
e.stopImmediatePropagation();}
return false;},
!window.opera);