Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

I would like to remove the default behaviour of <space> (to switch to the other pane). So, I can use it as a "leader" key, to put various commands under it.

For example, I have created the following. Which I have in also in Vim and committed to muscle memory.

" Yank dir-path, path and filename into the clipboard (escape spaces)
nnoremap <wait> <space>yd :!printf %d | pbcopy<cr>
nnoremap <wait> <space>yf :!printf %f:p:gs? ?\\ ? | pbcopy<cr>
nnoremap <wait> <space>yF :!printf %f:gs? ?\\ ? | pbcopy<cr>

" clear highlighting
nnoremap <wait> <space>h :nohl<cr>

The above commands do work. However pressing <space>x with an unassigned key x switches the pane. Typos happen sometimes and lead to a switch of the pane. I would like to prevent this and completely disable <space> for switching panes. Any ideas how to achieve that? unmap <space> says there no such normal mode mapping.

1 Answer

0 votes
by

As in Vim, builtin mappings are always there, but you can map them to do nothing with:

nnoremap <space> <nop>
by

Thank you! That disables <space>.

I have a small problem remaining. With the config in my question, if I press <space>f, I see the menu showing possible further keys: f, F, d in my case. Now, if I now press <esc> to abort, the pane is switched. It seems <space> retains the built-in mapping in that case. Can I somehow prevent this?

That's not a big deal. But maybe you have a hint here as well ;).

by

Possible workaround:

nnoremap <space>y<esc> <nop>

I think you've discovered a bug here, <space> should be expanded to <nop> in this case. Thanks.

by

It seems retains the built-in mapping in that case.

I think you need to use nmap instead of nnoremap if you want to retain the previous behavior. noremap doesn't follow any changes. At least that's how it is done in vim I believe.

by

Pressing <space><esc> should lead to execution of <nop><esc> in this case. Kind of those nnoremap <wait> <space>* mappings shouldn't matter as none of them were matched due to <esc>.

by

[...] <space> should be expanded to <nop> in this case.

That was wrong, input should just be dropped on Esc after an ambiguous input, which is what Vifm does since v0.14.1.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...