vimperator-labs icon indicating copy to clipboard operation
vimperator-labs copied to clipboard

Cannot map <space>

Open pevu opened this issue 10 years ago • 12 comments

This doesn't work:

noremap f

This does:

noremap F

They both show up as mapped keys, meaning I can :unmap afterwards, but the issue remains.

Space is a very conveniently placed key for just about everything, would be a shame to give it up to scrolling. And the default F is not in a convenient location for me (using Dvorak).

(Firefox 30, Windows 8.1 x64)

pevu avatar Jul 20 '14 16:07 pevu

Space (and a few other keys like Enter) unfortunately has some places where it is hard coded, so I agree with you about the bug, but there is nothing simple we can fix that without testing it properly for accessibility.

On Sun, Jul 20, 2014 at 6:52 PM, pevu [email protected] wrote:

This doesn't work:

noremap f

This does:

noremap F

They both show up as mapped keys, meaning I can :unmap afterwards, but the issue remains.

Space is a very conveniently placed key for just about everything, would be a shame to give it up to scrolling. And the default F is not in a convenient location for me (using Dvorak).

(Firefox 30, Windows 8.1 x64)

— Reply to this email directly or view it on GitHub https://github.com/vimperator/vimperator-labs/issues/10.

maxauthority avatar Jul 28 '14 14:07 maxauthority

This has been frustrating me in Muttator as well; I use Space in Vim to toggle folds, and I'd expect Enter to open the currently-selected email; however, with the following key mappings, neither key has any effect:

nnoremap <Space> za
nnoremap <CR> M

whitelynx avatar May 01 '15 14:05 whitelynx

I've been trying out vimperator and this issue isn't letting me pass space through to videos, is there a way that we can make space pass through to the webpage (but not remapping it, as per this issue), so that we can play/pause videos and other things? Firefox handles scrolling too in this case.

jgkamat avatar Aug 04 '15 05:08 jgkamat

Is there a good way for me to find all the places where Space is hard coded? I would like a make a fork where space can be mapped. I use space for leader in vim and I would really love the same in vimperator.

adamryman avatar Aug 04 '15 22:08 adamryman

I modified one line in my local zipped copy of vimperator and I seem to have the functionality I want.

https://github.com/vimperator/vimperator-labs/blob/master/vimperator/content/config.js#L305

"<Space>": modes.NORMAL | modes.INSERT,

To

"<Space>":  modes.INSERT,

And now I can map leader to Space.

If anyone else wants to do this just navigate to your firefox profile/extensions (i.e. ~/.mozilla/firefox/$YOURPROFILE.default/extensions) and edit your vimperator zip. (vim can do this if you have zip and unzip installed)

Then modify content/config.js as I did, save, quit, and restart firefox. Bam, you can map space.

What problems may I have by doing this? If I do run into any, I will post them here.

adamryman avatar Aug 04 '15 22:08 adamryman

@adamryman no repro here. Perhaps one of us is missing something necessary?

I made the change you described to content/config.js, updated my .vimperatorrc leader mapping aslet mapleader="<space>", and restarted Firefox. I also tried let mapleader="\<space>", in case Vimperator carries over Vim's syntax here. Neither way caused my <leader> mappings to work with space -- hitting space just paged down in FF (39.0).

jwhitley avatar Aug 05 '15 05:08 jwhitley

@jwhitley

That is interesting, those do not work for me either.

I realize now that I use leaders in a very nonstandard way. In vim, I leave let mapleader="\" by default and then I map <Space> <Leader> because this allows me to see a \ with set showcmd when I press space, rather than just seeing a space (i.e. nothing).

I did the same in vimperator without realizing it. But it does work if you want this functionality.

So follow my instructions and to use space as a leader key do the following

:let mapleader="\"
:map <space> <leader>
" And as an example, feel free to try something else
:map <leader>j :echo "Hello, World; Leader is now Space"<Return>

Then try pressing <space>j and seeing if it worked.

Let me know if this is functionality you wanted. It works for everything I wanted it to.

adamryman avatar Aug 05 '15 20:08 adamryman

@adamryman Brilliant! That does it. It's a complete hack, but it does the job for now. The mental switching of <leader> between Vim and Vimperator has been a major pain; I haven't created any <leader> bindings that I actually use in Vimperator as a result. Thanks.

jwhitley avatar Aug 05 '15 20:08 jwhitley

@jwhitley Glad it worked for you! As far as the mental switch between <leader> in vim and vimperator, I agree completely. I did not create any <leader> bindings until now either.

Very happy that my little hack helped someone else out.

If anyone wants to know how I did this, I just searched the codebase for "<space>" and "<Space>" and changed the only line that seemed to be related.

@jwhitley if you come across any weird issues that are related to this, please post them here. Also I will be studying your .vimrc, I see you have nice fugitive leader bindings that I may borrow haha.

adamryman avatar Aug 05 '15 20:08 adamryman

I'm used to map my Key to / for searching. Using the tip from @adamryman worked like a charm.

tuxflo avatar Nov 12 '15 22:11 tuxflo

@adamryman 's hack is really helpful.

If somebody doesn't want to modify your local vimperator, add the following code hook in .vimperatorrc file.

" To Enable map <Space>
js <<EOM
  window.addEventListener('keypress',function (event) {
    var code=event.charCode;
    if ((liberator.mode === modes.INSERT && modes.extended === modes.MENU)
    ||(liberator.mode ==modes.NORMAL && code==32)
    ||(liberator.mode ==modes.COMMAND_LINE && code !=32)){
      let map = mappings.get(liberator.mode, events.toString(event));
      if (map) {
        event.preventDefault();
        event.stopPropagation();
        map.execute();
      }
    }
  },false);
EOM

" My Customization
map <Space> <Leader>

fx-kirin avatar Nov 20 '15 01:11 fx-kirin

Brilliant work: @adamryman @fx-kirin .

@fx-kirin I'm using your patch in my .vimperatorrc at it works a treat. Thank you.

tecfu avatar May 19 '16 16:05 tecfu