Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

I would like to map backspace to move up one level as h only when I am in normal mode. Here is what I am using in vifmrc:

nnoremap <bs> gh

But, it does not work. How can I achieve this?

Thank you

1 Answer

+1 vote
by
selected by
 
Best answer

See description of <bs> here and also map <c-h>:

Most of the time they are defined consistently and don't cause surprises, but <c-h> and <bs> are treated differently in different environments (although they match each other all the time), that's why they correspond to different keys in vifm. As a consequence, if you map <c-h> or <bs> be sure to repeat the mapping with the other one so that it works in all environments.

by

The manual says

As a consequence, if you map <c-h> or be sure to repeat the
mapping with the other one so that it works in all environments.

so, I tried this:

map <bs> gh
map <c-h> gh

It didn't work.

The manual also says

Alternatively, provide your mapping in one form and add one of the
following:
" if mappings with <c-h> in the LHS work

map c-h bs

" if mappings with in the LHS work

map bs c-h

So, I tried the followings:

map <bs> gh
map <bs> <c-h>

But, it still does not work. I tried multiple other combinations, but with no luck!

Am I doing it wrong?

by

It might be that ncurses doesn't understand which key is Backspace for your terminal. Make sure $TERM is set correctly.

by
echo $TERM

returns xterm-256color

What should be the correct setting for $TERM?
Also, which of the solutions that I tried is the correct one?

by

What should be the correct setting for $TERM?

Depends on your terminal and whether you're using terminal multiplexer. Inside tmux it should be tmux-256color.

Also, which of the solutions that I tried is the correct one?

Either one should work.

by

I am using tmux and alacritty, so I changed it to tmux-256color and am using this in my vifmrc:

map <bs> gh
map <c-h> gh

It still does not work.

I tried other terminals, with no luck!

Can you think of anything else that I can try?

Thank you

by

This sounds weird. Does Backspace work in command-line mode? Do you see it working if you do:

noremap <bs> j
noremap <c-h> j

?

by

I just tried this. It does not work (backspace does not make the file list to go one down).

I tried it with and without tmux and with two different terminal emulators.

by

But it works in comman-line mode? Are you sure it gets mapped in normal mode? Do you see the mapping in :noremap <bs>? You can also try mapping to <del>.

by

By command-line mode, do you mean when I press : and then I can type commands like :execute ... ?

If yes, then the backspace works there just find (deletes the character before cursor). Does this mean that the mapping to j is ignored? or the noremap is just for normal mode? (sorry, I am very new to vifm and vim and trying to learn)

by

By command-line mode, do you mean when I press : and then I can type commands like :execute ... ?

Yes. noremap is only for normal mode, map is for normal and visual modes. Have you tried <del>?

by

I just tried both of the followings:

noremap <del> j

and

noremap <del> gh

None of them make any different in normal or command-line mode. Del key works as expected in command-line mode and doesn't do anything in normal mode.

I just restarted my system and noticed that backspace is working (moving up one level just like h). But this is what I have in vifmrc:

noremap <bs> j
noremap <c-h> j

How does j make it go one level up?

by

How does j make it go one level up?

It can't. Have your run :noremap <bs> menu? You probably mapped it somewhere else (maybe you're editing wrong vifmrc).

by

How can I run :noremap <bs> menu?

I just tried different combinations and it turned out that this is what makes backspace work:

map <del> gh

I changed it to

map <del> j

and it also makes backspace to press j. Is this normal?

by

How can I run :noremap <bs> menu?

This is just a command-line command.

Is this normal?

Yes, although probably rather rare and missing from documentation. Backspace works in command-line mode because there is a mapping for <del>.

by

Does this remove any mapping to backspace?

:noremap <bs>

So, basically the issue was that backspace key is defined as delete key in my system?

by

Does this remove any mapping to backspace?

:noremap <bs>? No, it just opens a menu.

So, basically the issue was that backspace key is defined as delete key in my system?

Well, it's called ASCII delete key, but it's a backspace. A third possible id for backspace. Not sure why it works like this for you, I'd expect it to depend on terminal.

by

When I enter :noremap <bs> I get the following error

Too few arguments

Should I press a specific key after the command?

by

Sorry, I forgot that noremap won't work, use nmap instead (nnoremap works the same).

by

thank you - now I see the meanu

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