vifm：为铁杆 Vim 爱好者提供的终端文件浏览器
Vim vifm 文件管理器

> 
> 让我们探索一个基于终端的文件浏览器，可以使用 Vim 风格的键绑定。
> 
> 
> 


![](/data/attachment/album/202111/20/103256stau7uhetccj7uun.png)


当在命令行中浏览 [Linux 目录结构](https://linuxhandbook.com/linux-directory-structure/) 时，人们经常依赖 [cd 命令](https://linuxhandbook.com/cd-command-examples/)。


这也没什么不好，因为你登录到任何一个 Linux 系统上都有 `cd` 命令。


然而，如果系统是由你维护的，你想更直观地看到目录，那么文件管理器比 `cd` 或 `tree` 命令要好得多。


是的，你也可以在终端中找到文件管理器。它们可能不如 Nautilus 这样的图形界面应用，但仍然比普通的老命令好。


有几个 [TUI](https://itsfoss.com/gui-cli-tui/) 文件浏览器，我们已经介绍了其中的几个。今天，我们来看看 `vifm`。


### vifm 简介


![](/data/attachment/album/202111/20/103304e318nfadf21c8aqg.png)


[vifm](https://github.com/vifm/vifm) 是一个命令行工具，它是一个文件管理器，导航和操作文件系统对象的键绑定与 Vim 类似。如果你不清楚我所说的“文件系统对象”是什么意思，它们是文件、目录、符号链接、硬链接等。


除了非常直观的 Vim 交互键绑定外，下面是 `vifm` 为你提供的一系列功能：


* 一个就在你的终端中的快速文件管理器
* 从文件管理器内编辑文本文件
* `vifm` 使用 curses 界面
* `vifm` 是跨平台的（在 Cygwin 的帮助下甚至可以在 Windows 上工作；它应该可以，但我没有测试过）
* 支持 Vim 风格的键绑定输入，如 `dd`、`j`、`k`、`h`、`l` 等
* [vifm 插件](https://github.com/vifm/vifm.vim) 可以在 Vim 中使用，这样就可以通过 Vim 打开文件
* 支持 Vim 命令的自动补完
* 支持多个面板
* 可以使用 [或不使用] 正则表达式进行批量重命名


### 在 Linux 上安装 vifm


`vifm` 软件包并不算新，因此在默认情况下，即使是“稳定”发行版（如 Debian）的软件库中也很容易找到它。


在 Debian 和基于 Debian 的发行版（如 Ubuntu、Pop!\_OS、Mint 等）之上，你可以 [使用 apt 软件包管理器](https://itsfoss.com/apt-command-guide/) 来安装 `vifm`：



```
sudo apt install vifm

```

使用 [pacman 软件包管理器](https://itsfoss.com/pacman-command/) 在 [基于 Arch 的 Linux 发行版](https://itsfoss.com/arch-based-linux-distros/)上安装 `vifm`：



```
sudo pacman -S vifm

```

`vifm` 在 Fedora 和 RHEL 仓库中也有；用 DNF 软件包管理器安装它：



```
sudo dnf install vifm

```

安装好了 `vifm`，你可以简单地在终端输入 `vifm`，像下面这样，然后启动它：



```
vifm

```

### vifm 的用户界面


当你第一次启动 `vifm` 时，默认情况下，它启动时显示你当前所在的目录的概览。你还会注意到，`vifm` 默认使用两个窗格。


![默认的 vifm 界面，包括一个正常的视图（隐藏的文件不可见）和两个默认打开的窗格](/data/attachment/album/202111/20/103304an2qml4oqhi52iol.jpg)


如果你对界面感到困惑，只需尝试按 `j` 键将光标向下移动一行，按 `k` 键将光标向上移动一行。你可以通过按 `h` 键向上移动一级目录。就像 Vim 中一样！


如果你的光标目前在一个文件上，按 `l` 键将在 Vim 中打开该文件（如果没有另外说明的话）。但如果你的光标在一个目录上，按 `l` 键将导航到该目录并显示其内容。


你也可以通过按 `Ctrl + g` 键绑定，从文件管理器中获得关于文件或目录的详细信息。


![ 键绑定如何显示目录/文件信息的屏幕截图](/data/attachment/album/202111/20/103305b5p4p733botb4u42.jpg)


你可以按 `za` 键来显示被隐藏的文件和目录（开头有 `.` 的文件和目录默认是隐藏的）。如果这些特殊的文件和目录没有被隐藏，按 `za` 键将会隐藏它们。


你可以用 `zo` 键绑定一直显示隐藏的文件和目录，或用 `zm` 键绑定使这些项目一直不可见。


![举例说明，当你按下  键绑定时的情况](/data/attachment/album/202111/20/103305u29fgcchgcuvt9vu.jpg)


### 总结


由于它是基于 Vim 的，你可以用 vifmrc 文件来配置它。在 [vifm wiki](https://wiki.vifm.info/index.php/Main_Page) 上有最新的默认绑定键的速查表，在 [这里](https://vifm.info/cheatsheets.shtml)。这个项目的文档非常好。


![vifm 默认按键绑定](/data/attachment/album/202111/20/103305eojv43boujj1dqy3.jpg)


`vifm` 是一个了不起的文件管理器，特别是对于 Vim 用户来说，因为它与 Vim 生态系统整合得非常好。它将许多 Vim 的功能和按键绑定整合到一个文件管理器中。默认的双窗格布局使其更具生产力。


不要犹豫，尝试一下 `vifm`。它真的是一个了不起的命令行工具。




---


via: <https://itsfoss.com/vifm-terminal-file-manger/>


作者：[Pratham Patel](https://itsfoss.com/author/pratham/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[wxy](https://github.com/wxy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

When it comes to navigating through the [Linux directory structure](https://linuxhandbook.com/linux-directory-structure/) in the command line, people often rely on the [cd command](https://linuxhandbook.com/cd-command-examples/).

And nothing wrong with it because you’ll get the cd command on any Linux system you log in.

However, if the system is maintained by you and you want to have a better view of the directories, a file manager does a lot better than the cd or tree command.

Yes, you can get file managers in the terminal as well. They may not be as good as the GUI ones like Nautilus but still better than the plain old commands.

There are several [TUI](https://itsfoss.com/gui-cli-tui/) file browsers and we have covered a few of them on It’s FOSS. Today, we look at vifm.

## What is vifm?

![vifm screenshot](https://itsfoss.com/content/images/wordpress/2021/11/vifm-screenshot-800x309.png)

[vifm](https://github.com/vifm/vifm) is a command line tool that is a file manager with key bindings for navigation and file system object manipulation that are similar to vim. In case you are wondering what I meant by “file system objects”, they are files, directories, symbolic links, hard links etc.

Along with the very intuitive vim interaction key bindings, below is the set of features that vifm offers you

- A fast file manager right in your terminal
- Edit the text file from the file manager itself
- vifm uses the curses interface
- vifm is cross platform (can even work on Windows with the help of Cygwin; it should work but I have not tested it)
- Supports vim style key binding inputs like dd, j, k, h, l etc
- The
[vifm plugin](https://github.com/vifm/vifm.vim)is available to be used inside vim for opening file(s) through vim - Auto complete support for the vim commands
- Support for more than one panes
- Allows batch rename with [or without] regex

## Installing vifm on Linux

The vifm package isn’t new and therefore is readily available in even the “stable” distributions’ (like Debian) repositories by default.

On Debian and Debian based distros (like Ubuntu, Pop!_OS, Mint etc), you can [use the apt package manager](https://itsfoss.com/apt-command-guide/) to install vifm:

`sudo apt install vifm`


Use the [pacman package manager](https://itsfoss.com/pacman-command/) to install vifm on [Arch-based Linux distributions](https://itsfoss.com/arch-based-linux-distros/):

`sudo pacman -S vifm`


vifm is also available in the Fedora and RHEL repositories; install vifm with the DNF package manager:

`sudo dnf install vifm`


Once you have vifm installed, you can simply type vifm your terminal – like below – and start vifm

`vifm`


## The vifm user interface

When you launch vifm for the first time, by default, it will launch with the overview of the directory that you are currently in. You will also notice, that vifm uses two panes by default.

![01 two panes 1](https://itsfoss.com/content/images/wordpress/2021/11/01_two_panes-1-800x600.webp)

If you find yourself confused at the interface, simply try pressing the j key to move the cursor down one row, and press the k key to move the cursor up one row. You can move up one directory by pressing the h key. Just like vim!

If your cursor is currently on a file, pressing the l key will open the file in vim (if not stated otherwise). But if your cursor is on a directory, pressing the l key will navigate in the directory and show you the directory contents.

You can also get details about a file or directory from the file manager by pressing the Ctrl + g key binding.

![02 ctrl g info](https://itsfoss.com/content/images/wordpress/2021/11/02_ctrl_g_info-800x600.webp)

You can press the keys “za” to either show files and directories that are hidden (files and directories with a period at beginning are hidden by default). If these special files and directories are not hidden, pressing za will hide them.

![03 toggle dotfile visibility](https://itsfoss.com/content/images/wordpress/2021/11/03_toggle_dotfile_visibility-800x600.webp)

You can either permanently show hidden files and directories with the “zo” key binding and never make these items visible with the “zm” key binding.

## Conclusion

Since it is based on Vim, you can configure it using the vifmrc file. The [vifm wiki](https://wiki.vifm.info/index.php/Main_Page) has the latest default keybinding cheatsheet located [here](https://vifm.info/cheatsheets.shtml). The project is very well documented.

![vifm key binding cheatsheet](https://itsfoss.com/content/images/wordpress/2021/11/vifm-key-binding-cheatsheet-800x561.webp)

vifm is an amazing file manager, specially for Vim users because it integrates so well with the Vim ecosystem. It incorporates many vim features and key bindings into a file manager. The default two-pane layout makes it more productive.

Do not hesitate to give vifm a try. It really is an amazing command line tool!