Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

Open file from vifm in split view

+3
−0

I use vifm in split mode - it always shows two vertically separated windows each with a directory listing. From there I can open files using the right arrow. However when I open a text file, vifm goes to the background and vi is in the foreground covering the whole screen. Is it possible to have vi only open in the window from where I open the text file (ie. half the screen), and have the other window (the other half of the screen) continue to show vifm and the directory listing?

I'm using debian 11 if that matters.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+3
−0

From the FAQ:

No, unfortunately it's not possible. Allowing this would require embedding terminal multiplexer into Vifm, which is kinda silly because it is a file manager. The compromise is to run Vifm inside terminal multiplexer and provide some integration between them (there is already some builtin support for GNU Screen and tmux in Vifm, e.g. :screen, :ls).

However, there are several options to prevent the editor from blocking Vifm.

Use Gvim

A GUI editor opens in a new window, leaving Vifm's terminal free.

:set vixcmd="gvim &"

Note this option really needs to specify a Vi editor if you want external editor tasks to work. In other words, if you try, for example,

:set vixcmd="xedit &"
:set vixcmd="xterm -e nano &"

that will work fine for normal file editing, but will break q: and :rename. The reason is explained in the manual:

vicmd

Command used to edit files in various contexts. Ampersand sign at the end (regardless whether it's preceded by space or not) means backgrounding of command.

Background flag is ignored in certain context where vifm waits for the editor to finish. Such contexts include any command that spawns editor to change list of file names or a command, with :rename being one example. ’-f’ is also appended to prevent forking in such cases, so the command needs to handle the flag.

Additionally ’+{num}’ and ’+'call cursor()'’ arguments are used to position cursor when location is known.

Use a terminal multiplexer

If you run Vifm under Tmux or Screen and activate multiplexer integration with the :screen! command, then the files are opened in a new Tmux or Screen window.

Open a new terminal for the editor

Vifm supports binding different commands to different mime-types (as listed by file -i filename) or file patterns. For example,

:filextype <text/*> xterm -e vim %f &

opens files whose mime-type matches text/* in a new terminal with Vim, while

:filextype *.txt xterm -e vim %f &

does the same for all files with a .txt extension, and since the Vim terminal is put in the background, the Vifm terminal does not block.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Works for me (1 comment)

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate