Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot map <space> #10

Open
pevu opened this issue Jul 20, 2014 · 12 comments
Open

Cannot map <space> #10

pevu opened this issue Jul 20, 2014 · 12 comments

Comments

@pevu
Copy link

pevu commented Jul 20, 2014

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 pevu changed the title Cannot map \<space\> Cannot map <space> Jul 20, 2014
@maxauthority
Copy link
Member

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 notifications@github.com 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
#10.

@whitelynx
Copy link

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

@jgkamat
Copy link

jgkamat commented Aug 4, 2015

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.

@adamryman
Copy link

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
Copy link

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.

@jwhitley
Copy link

jwhitley commented Aug 5, 2015

@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).

@adamryman
Copy link

@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.

@jwhitley
Copy link

jwhitley commented Aug 5, 2015

@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 added a commit to jwhitley/dotfiles that referenced this issue Aug 5, 2015
@adamryman
Copy link

@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.

@tuxflo
Copy link

tuxflo commented Nov 12, 2015

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

@fx-kirin
Copy link

@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>

@gkatsev gkatsev added the medium label Jan 27, 2016
@tecfu
Copy link

tecfu commented May 19, 2016

Brilliant work: @adamryman @fx-kirin .

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests