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

New here.

What would be the best way to have multiple ways to open a file (really just 2).


Hit enter to open a CSV file in vim and hit Ctrl-Enter to open it in Excel. I see the same need in my source code too. Sometimes i want to quick edit and other times I want to open up MacVim in a separate window, etc.

Is there a configuration path I should be looking at or some other way of thinking here?

1 Answer

0 votes

I don't think you can get Ctrl-Enter to work (it seems to work in terminal Vim though, but I don't understand how it does that), but in general you can do:

nnoremap o !your app %f

If you want to have it more systematic, then you might want to configure associations in vifmrc:

filetype *.csv Excel %c &
filetype *.c,*.cpp MacVim %c &

nnoremap E :edit<cr>

It's somewhat inverted though, it opens Vim on E and other applications on Enter, so you might want to remap things

nnoremap <cr>
    \ : if filetype('.', 1) == 'dir'
    \ |     execute 'normal! l'
    \ | else
    \ |     execute 'normal E'
    \ | endif<cr>
nnoremap o <cr>

This opens Vim on E and uses associations on Enter. The mappings won't change the behaviour of l.

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.