Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Open file from vifm in split view
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.
1 answer
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
mulllhausen |
Thread: Works for me good enough :) i use gnu screen so tabbing between the file in vi and vifm is good. btw i put |
Oct 30, 2021 at 13:03 |
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.
0 comment threads