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

When using the Lenovo Z51 laptop, I like to use the key with a square and a cross inside (called stop/exit) which closes the active window like Alt-F4 would.

With VIFM, when I open a Vim document with the ee key that I mapped as follows: nnoremap ee :execute '!' $VIFM_TERMINAL ' vim %c &'<cr> and I close the document with the stop/exit key, VIFM remains open.

However, open a Vim document in VIFM by pressing the Enter key and then close it with the stop/exit key, the Vim document closes and VIFM closes too. How can I make the Enter key behave the same way as the ee mapping? Thank you.

1 Answer

0 votes
by
edited by
 
Best answer

Seems like you're just closing the active window (terminal) in both cases. You can map <cr> similarly:

nnoremap <cr> : if filetype('.', 1) == 'dir'
            \ |     open
            \ | else
            \ |     execute '!'.$VIFM_TERMINAL 'vim %c &'
            \ | endif<cr>

An alternative is changing 'vicmd' option, but there a script may be necessary to keep everything working as expected.

Edit: added 1 parameter to resolve symbolic links.

Edit 2: this change fixes :open for symbolic links to directories when vifm is not present in $PATH. Until then, use cd %c as a functionally-equivalent workaround.

by

@xaizek working like a charm !

by

Thanks xaizek for the new Version of the code - more reliable with directory link I post below:

nnoremap <cr> : if filetype('.', 1) == 'dir'
            \ |     cd %c
            \ | else
            \ |     execute '!'.$VIFM_TERMINAL 'vim %c &'
            \ | endif<cr>
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.
...