Fzf Filter Upgrades Vim Workflows to Rival Visual Studio Code

Vim universe. fzf - command line fuzzy finder — Alexey Samoshkin

Alexey Samoshkin

Treating fuzzy search as an interactive Unix filter across shell tasks and buffer streams eliminates directory tree navigation, enabling legacy Vim to match modern graphical editors.

AI-assisted summary of Vim universe. fzf - command line fuzzy finder — original source. Check the original for full context.

Source published:

Key ideas

  • fzf operates as a general-purpose Unix filter that accepts generic input via standard input and outputs selections interactively to standard output. (0:08)
  • Beyond basic file searching, fzf integrates into shells for path completion, SSH host discovery, interactive process termination, and history browsing. (4:22)
  • The companion plugin fzf.vim replaces visual tree navigation with instant fuzzy searching across project files, buffers, help tags, and live ripgrep code queries. (7:18)
  • A notable limitation in Vim is the absence of out-of-the-box Most Recently Used (MRU) ranking, which requires alternative navigation habits or history workarounds. (10:04)

Detailed notes

## Background Published on YouTube by Alexey Samoshkin on April 17, 2019, this video introduces the command-line fuzzy finder fzf and its integration within shells and Vim. The accompanying description highlights fzf's versatility beyond simple file lookups—including SSH hostnames, process IDs, and directories—along with its companion plugin fzf.vim for navigating buffers, help tags, lines, and grep matches.

## TL;DR Alexey Samoshkin presents fzf as an interactive Unix filter that ingests standard input, enables instant fuzzy filtering, and outputs chosen selections directly to standard output. Across terminal shells, fzf streamlines tasks like changing directories, terminating processes, recalling command history, and connecting to SSH hosts, particularly when enhanced with previews from tools like bat. In Vim, the fzf.vim plugin replaces traditional file-tree browsing with high-speed file opening, buffer switching, line searches, and ripgrep queries. Although Samoshkin notes that fzf lacks native most-recently-used (MRU) sorting, he demonstrates how its speed and flexibility modernize the classic editor to match contemporary development environments.

## Atmosphere & style The presentation is instructional, pragmatic, and methodically paced, evoking the quiet focus of an experienced software engineer refining terminal workflows. Samoshkin delivers clear, deliberate commentary that demystifies abstract Unix paradigms while validating common friction points, such as mental fatigue caused by nested directory navigation. The overall experience feels clean and practical, emphasizing tangible efficiency gains and seamless muscle memory over flashiness.

## Bulletin - [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) fzf operates as a general-purpose Unix filter that accepts generic input via standard input and outputs selections interactively to standard output. - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) Beyond basic file searching, fzf integrates into shells for path completion, SSH host discovery, interactive process termination, and history browsing. - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) The companion plugin fzf.vim replaces visual tree navigation with instant fuzzy searching across project files, buffers, help tags, and live ripgrep code queries. - [10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) A notable limitation in Vim is the absence of out-of-the-box Most Recently Used (MRU) ranking, which requires alternative navigation habits or history workarounds.

## Key takeaways - [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) fzf acts as an interactive Unix filter that transforms standard input into standard output in real time. - [01:17](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=77s) Fuzzy matching ranks scattered character hits automatically, while a single quote prefix forces deterministic exact matching. - [01:17](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=77s) Search queries support multiple space-delimited tokens, prefix/suffix anchoring, negation, and multi-item selection with Tab. - [02:47](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=167s) The double-star (**) trigger sequence initiates contextual fuzzy completion directly within shell commands. - [02:47](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=167s) Built-in shell shortcuts streamline common operations: Ctrl+T locates files and Alt+C jumps into subdirectories. - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) SSH hostname completion automatically reads connection history and the user's ~/.ssh/config file. - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) Interactive process filtering allows users to search process tables and pipe chosen PIDs directly to kill. - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) Shell history search via Ctrl+R becomes a scrollable, fuzzy-filtered list pasting commands straight to the prompt. - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) External tools like bat, fd, and ripgrep can be plugged in to provide syntax previews and faster search backends. - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) Using fzf.vim with the :Files command eliminates the cognitive friction and context switching of visual filetrees like NERDTree. - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) Files selected in Vim can be opened in the current window, horizontal or vertical splits, or fresh tabs. - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) Adding a bang to Vim commands (such as :Files!) renders a full-screen layout with an expanded syntax preview. - [10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) fzf does not maintain built-in MRU file sorting in Vim, necessitating workarounds like Ctrl+^ or jump lists. - [10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) :Helptags allows users to discover Vim documentation without memorizing exact help keyword names. - [10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) :Lines and :BLines enable fuzzy searching through lines across all open buffers or within the active buffer. - [10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) :Rg leverages ripgrep for lightning-fast project-wide line searches accompanied by real-time previews.

## Detailed walkthrough ### [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) What is fzf? The Unix Filter Concept

Alexey Samoshkin introduces fzf, which stands for fuzzy finder, describing it as a general-purpose command-line fuzzy finder. While that official definition sounds succinct, Samoshkin notes that it fails to capture the true breadth and power of the tool, which had already accumulated over 20,000 stars on GitHub at the time. For people accustomed to working inside a terminal environment, the fundamental mental model to understand is the classic Unix filter: independent utilities linked in a pipeline that take input, transform it, and pass it onward to produce an end result.

```mermaid flowchart LR accTitle: fzf Unix Filter Pipeline Architecture accDescr: Diagram showing how fzf acts as an interactive Unix filter between standard input and standard output. subgraph Input ["Standard Input"] A["Input Stream (stdin)"] end subgraph Finder ["Interactive Filter"] B["fzf Dialog Window"] C["User Fuzzy Query"] A --> B C --> B end subgraph Output ["Standard Output"] D["Selected Item (stdout)"] B --> D end ```

In simple terms, fzf is just another Unix filter in that lineage. It ingests whatever stream arrives via standard input (`stdin`), launches an interactive finder dialogue for the user, and then writes the selected item directly to standard output (`stdout`). While a traditional command like `find` simply dumps results statically, fzf provides real-time responsiveness. As Alexey Samoshkin explains: “The real advantage of fzf of a regular find command is interactive search and instant feedback.”

[01:17](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=77s) Basic Fuzzy Search Syntax and Mechanics

Searching for files is such a ubiquitous scenario that simply entering `fzf` in the terminal without arguments immediately launches the search interface over the current directory. Because it relies on fuzzy matching, typing a few characters in sequence matches lines where those characters are scattered across the path, with exact matches automatically receiving a higher ranking score and appearing at the top of the interface. For users who prefer non-fuzzy deterministic searching, prefixing a search term with a single quote or running fzf with the exact flag switches it to exact-match behavior.

Although fzf does not natively support standard shell glob patterns like `*.sh`, it provides flexible filtering through space-delimited terms. Users can chain multiple search tokens, anchor searches to the beginning or end of a string, and negate patterns to strip out unwanted lines. Because fzf sends selections straight to standard output, it truly shines when piped into downstream utilities—such as inspecting file metadata or opening a selection in an editor. In addition, users are not restricted to choosing a single item; hitting the Tab key allows multi-selection across the list.

- Type characters separated across a path to trigger fuzzy rank scoring, where exact matches float to the top. - Prefix tokens with `'` (or pass the exact flag) to bypass fuzzy matching in favor of literal matches. - Combine multiple space-separated search terms, match string prefixes/suffixes, or invert matches via negation. - Use the `Tab` key to mark multiple files simultaneously for batch processing downstream.

[02:47](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=167s) Shell Integration: Fuzzy Completion and Directory Navigation

To eliminate friction in daily shell tasks, fzf features fuzzy completion triggered by a dedicated trigger sequence (`**`). Samoshkin demonstrates trying to locate a specific configuration file tucked away inside a dotfiles repository under a nested `system` path: rather than escaping to an external file manager like Midnight Commander or manually traversing subdirectories, typing a command followed by `**` and pressing Tab launches the fzf selector right in place.

Changing directories is another area radically streamlined by fzf. Traditional approaches in shells like Zsh rely on Tab completion or typing initial path segments, both of which require mental overhead when dealing with deep directory hierarchies. Samoshkin remarks: “Well for sure that's easier than typing a full path manually but still a bit painful with fzf changing directory is like a breeze.” While fzf indexes subdirectories in the background, users can immediately begin filtering by typing whichever directory names they recall best. For those who want to bypass the `**` trigger entirely, fzf ships with default keybindings: `Ctrl+T` to locate files and `Alt+C` (Option+C) to jump into directories.

[04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) Beyond Files: SSH Hosts, Process Management, History, and Previews

Because fzf operates on generic input streams, its utility extends far beyond file systems. For backend engineers juggling multiple remote machines, fzf pairs seamlessly with SSH: typing `ssh **` inspects the user's `~/.ssh/config` along with recent connection history to present a fuzzy-searchable list of hostnames and IP addresses. Similarly, terminating errant processes usually requires running `pgrep` to track down a process ID followed by a separate `kill` command; fzf collapses this into a single fluid interaction where process names are interactively searched and piped directly to `kill`.

```mermaid flowchart TD accTitle: Versatile Input Sources for fzf accDescr: Breakdown of various system sources feeding into fzf and downstream actions. subgraph Sources ["Input Sources"] H["SSH Config / Known Hosts"] P["Process Table (ps / pgrep)"] Cmd["Shell History"] end subgraph FZF ["fzf Interface"] UI["Fuzzy Interactive Selector"] Prev["bat Syntax Preview"] UI --- Prev end subgraph Actions ["Resulting Actions"] Conn["ssh user@host"] Term["kill -9 PID"] Exec["Refine / Execute Command"] end H --> UI --> Conn P --> UI --> Term Cmd --> UI --> Exec ```

The tool also modernizes command-line history. While traditional shells provide reverse incremental search via `Ctrl+R`, supercharging this with fzf opens a scrollable, fuzzy-filtered list that pastes the selected command directly onto the prompt for immediate editing. Samoshkin highlights several advanced flags, including attaching `bat` as a preview command for syntax highlighting and colored output, using Tab for multi-item selection, and binding custom actions like copying paths directly to the system clipboard. The underlying search backend can also be replaced—swapping GNU `find` for faster modern alternatives like `fd` or `ripgrep` (`rg`), and customizing default dialogue behavior via the `FZF_DEFAULT_OPTS` environment variable. Samoshkin emphasizes the cumulative impact: “It's a really prominent tool and has changed my common line habits making my development experience even more pleasant.”

[07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) Integrating fzf into Vim: Files, Splits, and Layouts

In the second half of the walkthrough, Samoshkin transitions to the Vim plugin wrapper (`fzf.vim`), which can be installed via package managers such as vim-plug. Historically, navigating project filetrees in Vim meant relying on sidebar plugins like NERDTree. However, hunting through deep folder trees visually creates friction. As Samoshkin observes: “Plus it makes an extra contact switch in my mind and finally when I open file I forgot why I need it so ner tree is a good solution to explore an unfamiliar project but to quickly open file in a timely fashion I use fzf.”

```mermaid flowchart LR accTitle: Vim fzf File Opening Workflow accDescr: Options for opening files located with fzf inside Vim. F["fzf:Files Prompt"] --> Sel["Select File"] Sel -->|"Enter"| Win["Current Window"] Sel -->|"Ctrl+V / Ctrl+S"| Spl["Split View (H/V)"] Sel -->|"Ctrl+T"| Tab["New Vim Tab"] ```

Running the `:Files` command brings up the familiar interactive finder inside the Vim viewport. Files can be opened into the current window, into horizontal or vertical splits, or into fresh tabs using standard fzf key modifiers. Common editor conventions can be mirrored by binding file discovery to shortcuts like `Ctrl+P`, `Ctrl+T`, or `<Leader>o` (where "o" stands for open file). Samoshkin configures his finder to occupy a clean 40% split at the bottom of the editor, with syntax-highlighted previews powered by `bat`. For larger screens or extensive directory structures, appending a bang (`:Files!`) launches the picker in a full-screen layout with preview text displayed prominently at the top.

[10:04](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=604s) MRU Limitations and Advanced Vim Workflows (Buffers, Tags, and Lines)

Samoshkin candidly highlights the main shortcoming of fzf in Vim: it does not maintain an out-of-the-box Most Recently Used (MRU) ranking. When switching rapidly between a small set of files, fzf does not automatically bubble the latest opened files to the top, requiring users to type their search terms repeatedly. Workarounds include relying on fzf's internal search history, cycling alternate files with `Ctrl+^`, or jumping back through cursor jump lists.

Beyond file navigation, `fzf.vim` exposes numerous specialized commands that leverage fuzzy finding across other Vim data:

- **Help Tags (`:Helptags`)**: Quickly discover Vim documentation topics when exact help keywords are unknown. - **Buffers (`:Buffers`)**: Restrict fuzzy selection specifically to loaded files rather than scanning the entire filesystem. - **Filepath Insertion**: Use completion bindings inside insert mode to complete and paste relative filepaths straight into code. - **Buffer Line Search (`:Lines` / `:BLines`)**: Search for strings across lines in open buffers without manually scrolling back and forth. - **Project-wide Ripgrep Search (`:Rg`)**: Execute line-level searches across an entire code repository and filter matches interactively with instant preview. - **Metadata and Navigation**: Search available Vim commands, snippets, filetypes, command histories, and color schemes on the fly.

Samoshkin concludes by encouraging users to feed arbitrary lists into fzf, arguing that this level of speed and ergonomics modernizes the classic editor: “With fzf wiim can now compete with other popular text editors out there like autum or Visual Studio code and become more attractive option for those willing to give it a try.”

## Notable quotes > [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) The real advantage of fzf of a regular find command is interactive search and instant feedback. — Alexey Samoshkin

## Mentioned fzf, Alexey Samoshkin, junegunn, fzf.vim, Unix, Vim, Zsh, Midnight Commander, SSH, bat, find, fd, ripgrep, NERDTree, vim-plug, Atom, Visual Studio Code

## Video description Check out how to search for files with command line fuzzy finder, https://github.com/junegunn/fzf, within a shell and in a Vim. fzf is not limited to file search only, and can be used with any - ssh host names, process IDs, directories. With accompanying Vim plugin, https://github.com/junegunn/fzf.vim, we can use it to search for help tags, available commands, buffers, lines in a file, grep matches, and more.

[Source](https://www.youtube.com/watch?v=qgG5Jhi_Els)

中文简报

Fzf 过滤器升级 Vim 工作流,体验匹敌 VS Code 将模糊搜索作为贯穿 Shell 任务和缓冲区数据流的交互式 Unix 过滤器,可免除目录树导航,让传统 Vim 媲美现代图形编辑器。 Alexey Samoshkin 将 fzf 呈现为一个交互式 Unix 过滤器,它接收标准输入,支持即时模糊过滤,并将所选内容直接输出到标准输出。在终端 Shell 中,fzf 简化了诸如切换目录、终止进程、召回命令历史以及连接 SSH 主机等任务,在结合 bat 等工具提供预览时尤为出色。在 Vim 中,fzf.vim 插件取代了传统的目录树浏览,实现了极速的文件打开、缓冲区切换、行搜索和 ripgrep 查询。尽管 Samoshkin 指出 fzf 缺乏原生的最近使用(MRU)排序功能,但他展示了其速度和灵活性如何使这款经典编辑器焕发新生,比肩当代开发环境。 fzf 作为一个通用 Unix 过滤器运行,通过标准输入接收通用输入,并交互式地将选择结果输出到标准输出。 (0:08) 除了基础的文件搜索,fzf 还集成到 Shell 中用于路径补全、SSH 主机发现、交互式进程终止以及历史记录浏览。 (4:22) 配套插件 fzf.vim 取代了直观的目录树导航,可在项目文件、缓冲区、帮助标签和实时 ripgrep 代码查询中实现即时模糊搜索。 (7:18) 在 Vim 中的一个显著局限是缺乏开箱即用的最近使用(MRU)排序,这需要替代性的导航习惯或历史记录变通方案。 (10:04)

Reading summary

Alexey Samoshkin presents fzf as a general-purpose Unix filter that brings real-time interactive fuzzy searching to command-line environments and Vim. By operating across standard input and standard output, the utility streamlines file discovery, process management, and editor workflows without relying on cumbersome manual navigation. The Unix Filter Model and Search Mechanics (0:08) At its core, fzf functions according to the standard Unix filter paradigm: it ingests text via standard input (`stdin`), launches an interactive fuzzy-matching dialog, and outputs the chosen entry to standard output (`stdout`). Unlike static utilities such as `find`, fzf evaluates keystrokes in real time, sorting matches by ranking score and placing exact matches at the top. For scenarios requiring literal precision, users can pass an exact-match flag or prefix tokens with a single quotation mark. Shell Integration and System-Level Operations (2:47) Beyond standalone file discovery, fzf integrates into shell routines via the `**` fuzzy completion trigger and native shortcuts such as `Ctrl+T` for file paths and `Alt+C` for directory changes. This eliminates the need to manually traverse deep folder hierarchies or rely on traditional Zsh Tab completion. The tool also updates reverse history search (`Ctrl+R`), returning a scrollable list that pastes commands back to the prompt for editing. Extending Beyond Files to SSH and Processes (4:22) Because fzf processes arbitrary input streams, its shell utility extends into system administration. Running `ssh **` reads host configurations and known connection histories into a fuzzy selector, while process termination combines `pgrep` searches and `kill` commands into a single interactive step. Users can further enhance performance and appearance by replacing GNU `find` with modern backends like `fd` or `ripgrep`, integrating `bat` for syntax-highlighted previews, or copying selections straight to the clipboard. Vim Workflows and Plugin Capabilities (7:18) Within Vim, the `fzf.vim` wrapper replaces visual tree explorers like NERDTree for direct file opening, which Samoshkin argues reduces context switching when accessing known files. The `:Files` prompt allows opening selections into the current window, splits, or new tabs, and can be customized into split or fullscreen layouts with preview windows. The plugin also provides specialized commands such as `:Buffers`, `:Lines`, `:Helptags`, and project-wide searching via `:Rg`. A noted limitation of fzf in Vim is the absence of built-in Most Recently Used (MRU) sorting, which requires workarounds like jump lists or search history when alternating between a small set of files. Nevertheless, Samoshkin maintains that fzf's speed and ergonomics allow Vim to rival modern editors like Atom and Visual Studio Code.

精炼阅读摘要

Alexey Samoshkin 指出,通用命令行模糊查找工具 fzf 本质上继承了经典的 Unix 管道过滤器模型,通过实时交互与即时反馈机制,大幅提升了终端操作与 Vim 文本编辑的效率。 Unix 过滤器架构与模糊匹配机制 (0:08) fzf 的核心设计符合经典的 Unix 过滤器模式:从标准输入(stdin)接收文本流,向用户展示交互式搜索窗口,并将最终选中的内容输出到标准输出(stdout)。与直接输出静态结果的传统 find 命令相比,Samoshkin 强调 fzf 的优势在于即时反馈与交互式搜索能力。在终端中直接运行 fzf 即可在当前目录启动搜索界面;算法支持分散字符匹配,并将精确匹配项自动排列在最前端。若需确定性匹配,可在词条前添加单引号或传入 exact 参数。 尽管 fzf 原生不支持类似 *.sh 的 Shell 通配符,但它支持由空格分隔的多词条组合查询、前缀/后缀锚定匹配以及取反排除操作。因为输出直接导向 stdout,用户可将选中结果方便地传递给后续命令以查看元数据或打开文件。此外,用户可以使用 Tab 键在列表中同时标记多项,以便进行下游的批量任务处理。 Shell 补全集成与多维数据源处理 (2:47) 为减少日常操作的摩擦,fzf 提供了以 ** 为触发序列的模糊补全能力。当在深层目录结构中寻找配置文件时,输入命令附加 ** 并按 Tab 键即可就地调出选择界面,避免了使用独立文件管理器或手动遍历路径。针对目录跳转,fzf 允许后台索引的同时直接输入片段进行过滤,比 Zsh 传统的 Tab 补全更加轻便;此外,工具还默认绑定了查找文件的 Ctrl+T 和跳转目录的 Alt+C(Option+C)快捷键。 由于处理的是通用文本流,fzf 亦可处理文件以外的多样化系统数据。例如输入 ssh ** 时,系统会读取 ~/.ssh/config 与近期连接历史以供筛选主机;在进程管理中,fzf 将 pgrep 查询进程 ID 与 kill 终止进程合并为一个流式步骤。通过 Ctrl+R,传统的逆向历史搜索升级为可滚动的模糊列表。底层搜索工具可替换为更为迅速的 fd 或 ripgrep(rg),并能结合 bat 工具提供带语法高亮的代码预览面板。 Vim 插件集成与窗口布局优化 (7:18) 在 Vim 生态中,通过 vim-plug 等包管理器安装 fzf.vim 能够替代 NERDTree 等侧边栏文件树插件。Samoshkin 认为,在大型或陌生的项目中遍历深层文件夹容易引发心智负担和上下文切换,甚至导致忘记打开文件的初衷;而通过 :Files 快速打开文件则更为及时。用户可以根据个人偏好将查找功能映射为 Ctrl+P、Ctrl+T 或 <Leader>o 等常用快捷键。 在交互界面中,选中的文件不仅能按 Enter 在当前窗口打开,还支持通过 Ctrl+V 或 Ctrl+S 拆分水平/垂直窗口,或通过 Ctrl+T 开启新标签页。在界面布局上,查找器可以配置为占用编辑器底部 40% 的分割区域,并配合 bat 展示语法高亮预览;在处理宽屏显示或庞大工程时,使用附带感叹号的 :Files! 命令可进入全屏模式,将预览窗口置于顶部以展示更多代码上下文。 高级检索功能与近期访问机制局限 (10:04) Samoshkin 指出了 fzf 在 Vim 中的主要不足:它开箱即用状态下不维护“最近使用”(MRU)的文件排序。当用户在少量文件之间高频切换时,最近打开的文件不会自动置顶,必须重复输入关键词进行过滤;目前的替代方案包括利用 fzf 内部的搜索历史、使用 Ctrl+^ 在候补文件间切换,或借助光标跳转列表(jump list)。 除去基础文件检索外,fzf.vim 还提供了多种针对编辑器内部数据的专用命令。例如使用 :Helptags 可以在关键词不完全匹配时搜索文档主题,:Buffers 用于在已载入的文件集合中选择,插入模式下的路径补全支持直接粘贴相对路径,而 :Lines 和 :BLines 则支持跨文件或当前缓冲区的行级检索。此外,通过 :Rg 运行项目范围的 ripgrep,可以实现即时过滤与预览。用户亦可随时模糊搜索 Vim 命令、代码片段、文件类型及配色方案。 Samoshkin 总结认为,fzf 允许将任意文本流重定向至交互界面的特性,使 Vim 在操作速度和人体工程学上具备了与 Atom、Visual Studio Code 等现代流行文本编辑器竞争的实力;但其在 Vim 内部缺乏内置的 MRU 文件权重排序,仍需依赖工作流技巧或历史记录进行权衡补充。

Detailed notes — zh

## Background 该视频由 Alexey Samoshkin 于 2019 年 4 月 17 日在 YouTube 平台发布。视频简介说明,本期内容主要演示如何在命令行 Shell 与 Vim 中使用通用模糊查找工具 fzf 搜索文件,并介绍其在 SSH 主机名、进程 ID、目录跳转等多场景下的应用,同时结合 fzf.vim 插件在 Vim 中检索帮助标签、命令、缓冲区、代码行及 grep 匹配项。 ## TL;DR 本期视频全面解析了命令行模糊查找利器 fzf 的核心原理与实战技巧。首先从 Unix 过滤器哲学切入,介绍了 fzf 的基本模糊匹配语法、Shell 补全(如目录跳转、SSH 连接和进程终止)以及整合 bat 的彩色预览与环境变量调优。随后深入 Vim 生态,对比了传统目录树插件 NERDTree 的痛点,展示了如何通过 fzf.vim 实现类似现代 IDE 的毫秒级文件直达、全屏预览、应对 MRU 限制的替代策略,以及在缓冲区切换、行定位和项目全文检索(`:Rg`)中的高阶工作流。 ## Atmosphere & style 整期视频呈现出极为扎实、干练且极客风十足的教学氛围。Alexey 的讲解条理分明、直奔主题,通过真实的终端与 Vim 编码操作直观对比传统操作的繁琐与引入 fzf 后的轻快流畅,给观众带来一种如同打通任督二脉般的效能愉悦感与掌控感。 ## Bulletin - [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) fzf 作为经典的 Unix 过滤器,通过接收标准输入并在交互弹窗中完成毫秒级模糊筛选,直接将用户选择结果输出至标准输出或下游命令。 - [03:19](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=199s) 结合 Shell 快捷键与双星号补全机制,fzf 能将目录跳转、SSH 连接、进程清理及历史命令反向搜索的操作摩擦降至最低。 - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) 在 Vim 中使用 fzf.vim 替代 NERDTree 等传统文件树插件,可显著减少层级翻找产生的心智上下文切换,带来类似现代 IDE 的快速跳转体验。 - [09:09](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=549s) fzf 默认不维护 MRU(最近使用)排序,但可通过搜索历史回溯、交替文件快捷键(Ctrl+^)以及光标跳转列表(Ctrl+O/I)有效弥补。 ## Key takeaways - [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) fzf 本质上是一个符合 Unix 哲学的文本流过滤器,读取 stdin、展示交互筛选界面并将选中项写入 stdout。 - [01:17](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=77s) 支持灵活的匹配语法,包括字符分散的模糊匹配、单引号前缀的精准匹配、空格代表的 AND 逻辑以及感叹号取反排除。 - [03:19](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=199s) 在 Shell 中通过 **<Tab> 触发补全,搭配 Ctrl+T(选文件)和 Alt+C(跳目录)可大幅加速终端路径导航。 - [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) 拓展至非文件场景:利用 ssh ** 自动读取 known_hosts、kill ** 模糊选择进程 PID,以及用 Ctrl+R 全屏回溯历史命令。 - [05:59](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=359s) 支持集成 bat 提供带语法高亮的实时文件预览,并可通过 FZF_DEFAULT_COMMAND 替换为 fd 或 ripgrep 以实现极速扫描与自动忽略规则。 - [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) 相较于 NERDTree 频繁展开折叠目录树造成的认知负荷,fzf.vim 的 :Files 让日常文件打开更契合心流状态。 - [09:09](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=549s) 在命令后追加感叹号(如 :Files!)可立即切换为顶部带大窗口代码预览的全屏模式,适合复杂排查与阅读。 - [09:09](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=549s) 针对缺乏原生 MRU 排序的问题,可结合搜索词历史、Vim 交替文件切换(Ctrl+^)和跳转列表(Ctrl+O/I)协同化解。 - [10:52](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=652s) Vim 生态全方位增强:利用 :Helptags 模糊查阅文档、:Buffers 管理活动工作集、:BLines 单文件行内秒跳,以及 :Rg 进行带预览的全项目正则检索。 ## Detailed walkthrough ### [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) 什么是 fzf:从 Unix 过滤器到交互式模糊搜索 Alexey Samoshkin 介绍了名为 `fzf` 的强大工具,其全称为“Fuzzy Finder”(模糊查找器)。尽管官方将其简短定义为“通用命令行模糊查找器”,但这一概括过于精炼,未能展现其丰富而强大的全貌。作为一个在 GitHub 上获得超过两万颗星的热门开源项目,fzf 值得每位命令行深度用户去探究其内部工作机制。 在类 Unix 环境中工作的人大都熟悉“Unix 过滤器”(Unix filters)的概念:多个独立的单一工具通过管道连接组合成处理流,一步步将初始输入转化为期望的输出。Alexey 解释道,从本质上讲,fzf 无非就是这样一个标准的 Unix 过滤器。它接收标准输入(stdin)的任何数据,启动一个交互式的查找弹窗供用户筛选,最后把用户选中的条目打印到标准输出(stdout)。与传统的 `find` 命令相比,fzf 最具颠覆性的优势在于其实时交互与毫秒级的即时反馈。 ```mermaid flowchart LR accTitle: fzf 的 Unix 过滤器工作流 accDescr: 展示数据从标准输入流入 fzf 交互界面并输出至标准输出的过程 subgraph InputStage ["数据输入"] A["标准输入 stdin<br>(文件列表 / 历史 / 进程)"] end subgraph FZFStage ["fzf 核心"] B["交互式模糊查找弹窗<br>(支持即时键入与多维过滤)"] end subgraph OutputStage ["数据输出与下游动作"] C["标准输出 stdout<br>(用户选中的条目)"] D["下游命令<br>(打开文件 / kill / 编辑器)"] end A --> B B --> C C --> D ``` 谈及该工具的核心本质,Alexey Samoshkin 概括道:“In simple terms fzf is just another Unix filter it reads whatever comes from stdin launch the interactive finder dialogue and writes the selected item to the stdout.” - **项目热度**:GitHub 拥有超过 20,000 颗 Star 的极高人气。 - **架构哲学**:完美契合 Unix 管道设计,遵循单一职责与文本流处理原则。 - **核心差异**:不同于 `find` 的静态批处理等待,fzf 在输入流建立的同时即提供动态按键过滤。 --- ### [01:17](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=77s) 模糊匹配语法与命令行基本操作 在最常见的文件搜索场景中,用户只需在终端敲入 `fzf` 并回车即可开启查找。fzf 内置强大的模糊匹配算法,允许用户连续输入任意几个字符,它便会自动匹配那些字符分散在整个路径字符串中的条目。在此排序规则下,精确匹配到连续字符的结果会被赋予更高的权重并置顶展示。 如果用户不希望进行模糊匹配,可以通过在前缀加上单引号 `'`(例如 `'text`)或者启动时附加 `--exact` 标志来强制进行精准字符串匹配。需要注意的是,fzf 本身不支持诸如 `*.sh` 这类的通配符(Glob patterns),但用户可以用空格分隔多个搜索词来实现“且”(AND)逻辑匹配;也可以使用前缀 `^` 来匹配行首、使用后缀 `$` 匹配行尾,或者使用叹号 `!` 来执行反向排除匹配(negation)。 由于 fzf 默认仅将选中的内容发送到标准输出,单凭其自身并不具备完整的执行能力,必须配合后续管道才能释放威力。例如,可以把 fzf 选中的文件传递给后续命令打印详细属性,或者结合文本编辑器直接打开。 Alexey Samoshkin 在演示精准匹配机制时强调:“If you don't like fuzzy prefix text with a single quote or run fzf with exact flag it doesn't support glob patterns so searching for star.sh would not work.” - **多选机制**:在选择界面中按下 `Tab` 键即可标记多个条目,一次性向标准输出传递多行结果。 - **组合逻辑**:通过空格分隔实现多个关键词过滤,结合 `!` 排除无关噪音。 - **典型用法**: - `fzf | xargs file`:查看选中文件的元数据信息。 - `$EDITOR $(fzf)`:直接在默认编辑器中打开模糊选中的文件。 - `history | fzf`:快速在历史命令中模糊翻查近期执行过的长指令。 --- ### [03:19](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=199s) Shell 目录切换与快捷键加速 为了在终端日常操作中更加顺手,fzf 提供了专门的模糊补全触发语法。许多用户常遇到类似场景:需要编辑 dotfiles 项目中的某个配置文件,只模糊记得文件名包含几个特定字母、且存放在名为 `system` 的目录下,传统做法往往是打开 Midnight Commander 等图形文件管理器层层点选寻找,而现在只需输入命令配合触发序列即可原地完成调用。 在 Shell 中切换目录同样迎来了质的飞跃。在使用 fzf 之前,Alexey 通常依赖 Zsh 的 Tab 自动补全,或者靠键入路径每一段的前几个字母后按补全展开,这种方式虽然比全手打路径轻松,但层级过深时依然繁琐痛苦。有了 fzf,目录跳转变得极其流畅轻巧。用户只需键入 `cd **` 再按下 `Tab` 键,即可触发模糊目录跳转界面。 除了 `**<TAB>` 触发序列,fzf 还预置了高效的原生快捷键,免去键入双星号的麻烦: - `Ctrl+T`:在当前命令行光标处唤起模糊文件查找,选中的路径会自动粘贴回命令行中。 - `Alt+C`(Option+C):快速模糊筛选子目录并直接进入该目录。 在对比传统跳转方式时,Alexey Samoshkin 感叹道:“Well for sure that's easier than typing a full path manually but still a bit painful with fzf changing directory is like a breeze.” --- ### [04:22](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=262s) 进阶 Shell 场景:SSH、进程终止与历史记录增强 鉴于 fzf 是通用的列表过滤器,其应用绝不仅局限于文件查找。对于经常需要在海量远程机器之间频繁切换的后端工程师而言,SSH 与 fzf 的结合堪称神器。当需要连接某台服务器却忘记具体全名时,输入 `ssh **` 并按下 `Tab`,fzf 会自动从 SSH 的 `known_hosts` 和本地配置文件中提取最近访问过的 IP 地址与 Host 名称,拉起交互界面供用户即时敲字选定。 另一个高频痛点是杀掉特定进程。传统流程是先用 `pgrep` 根据进程名搜索 PID,再复制或键入该 PID 执行 `kill`。而在 fzf 中,输入 `kill ` 并键入 `**<Tab>`,便会调出当前系统中所有正在运行的进程列表,用户可以在可视窗口中通过进程名字模糊定位并回车,一气呵成完成信号发送。 终端自带的 `Ctrl+R` 反向搜索功能虽好,但界面局促且缺乏上下文感知。通过 fzf 的集成,`Ctrl+R` 被注入了全新的活力:按下快捷键后会弹出一个多行的全局命令历史搜索弹窗,选中的指令会原样填入当前命令行提示符之后,方便用户在敲击回车前进一步做微调修改。 关于这套快捷体验,Alexey Samoshkin 评价道:“You might be using control r keyboard shortcut to search through your command history like this that's great but how about supercharging it with fzf like this.” - **SSH 快速跳转**:自动解析 `~/.ssh/config`,解决多集群服务器命名记忆负担。 - **两步合一的进程管理**:省去 `pgrep` + `kill -9 <PID>` 的手工复制操作,支持多选批量杀死进程。 - **历史回溯增强**:支持语法高亮与任意多关键字交集查询历史指令。 --- ### [05:59](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=359s) 交互界面配置:Bat 预览、自定义动作与环境变量 fzf 包含许多极具生产力的内置高级属性。其一是即时预览(Preview)窗口。在列表上下导航时,fzf 能够实时在侧边渲染当前选中项的具体内容。Alexey 表示,虽然预览功能可以接入任何命令行工具,但他个人偏好使用 `bat`,因为 `bat` 支持代码语法高亮与彩色输出,阅读体验极佳。 用户还可以为界面绑定自定义按键动作(Actions),例如按下特定快捷键直接将当前选中的文件绝对路径复制到系统剪贴板中,极大地减少跨应用拷贝路径的操作摩擦。 为了彻底发挥性能并契合个人习惯,fzf 暴露了灵活的环境变量进行全局调优: - `FZF_DEFAULT_COMMAND`:可用于替换底层的遍历引擎。传统的 GNU `find` 速度较慢且不支持忽略 `.gitignore`,Alexey 推荐改用现代 Rust 编写的 `fd` 或 `ripgrep`(rg)来喂入初始列表,不仅极速,还能自动过滤掉二进制文件和版本控制隐藏项。 - `FZF_DEFAULT_OPTS`:用于自定义弹窗外观、窗口布局高度、快捷键绑定规则及默认预览选项。 回顾日常使用收益,Alexey Samoshkin 总结道:“It's a really prominent tool and has changed my command line habits making my development experience even more pleasant.” --- ### [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) 走进 Vim 生态:抛弃 NERDTree 拥抱快速文件跳转 视频的下半部分聚焦于 Vim 编辑器用户的实际收益。fzf 官方提供了针对 Vim 的插件扩展(`fzf.vim`),用户可以使用常见的插件管理器(如 `vim-plug`)一键安装。安装完成后,Vim 内部便获得了一整套以 fzf 为内核的强力指令。 在接触 fzf 之前,Alexey 主要依赖知名的 NERDTree 插件来查看项目目录树并定位文件。然而在实战中,用目录树往往需要不断展开和折叠目录层级,花费大量时间寻找文件;更糟糕的是,频繁在文件树与代码之间切换会产生剧烈的心智上下文切换(Context switch),经常出现“好不容易找到并打开了文件,却突然忘了自己最初为什么要打开它”的尴尬情况。Alexey 认为,NERDTree 适合用于了解陌生的全新项目架构,而对于日常开发中争分夺秒地快速打开已知文件,fzf 才是最优解。 在 Vim 中直接运行 `:Files` 指令,便会唤起与 Shell 终端完全一致的交互界面。输入关键词模糊筛选文件后回车即可打开。除了直接在当前活动窗口载入外,fzf.vim 还支持按键映射将文件打开至水平分屏、垂直分屏或全新的 Tab 页中。 为了达到类似现代 IDE(如 VS Code、Sublime Text)中 `Ctrl+P` 的疾速体验,Alexey 建议配置专属快捷键。他个人将按键绑定为 `<Leader>o`(`o` 代表 open file),也有很多人习惯沿用 `Ctrl+T` 或 `Ctrl+P`。 针对目录树插件的局限性,Alexey Samoshkin 直言:“NERD tree is a good solution to explore an unfamiliar project but to quickly open file in a timely fashion I use fzf.” --- ### [09:09](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=549s) Vim 中的文件预览、全屏模式与 MRU 限制应对 在 Vim 中检索文件时,fzf 同样继承了终端下的 `bat` 语法高亮预览功能。默认情况下,Alexey 将交互窗口的高度设置为占屏 40%,悬浮在编辑器底部。如果项目复杂或代码行较长、需要更大的阅读空间,只需在命令后追加一个感叹号(例如使用 `:Files!`),fzf 就会瞬间切换为全屏显示模式,同时将代码预览窗格置于顶部,视野十分宽阔。 多选编辑在 Vim 中同样自然:使用 `Tab` 键勾选多个文件,按下回车即可一次性把它们作为多个 Buffer 同时载入编辑器。 Alexey 坦率地指出了 fzf 目前存在的一个明显短板:它本身并不维护“最近最常使用”(MRU, Most Recently Used)的文件排序。如果用户先后打开了 A、B、C 三个文件,再次呼出 `:Files` 时,这几个文件不会被自动排在列表顶部。当开发者在少数几个文件之间来回反复切换时,若两端工具都不加辅助,就必须一遍又一遍地重新输入关键词过滤。 为了缓解这一痛点,Alexey 梳理了三个实用的替代规避方案: 1. **搜索历史回溯**:fzf 会自动记录每一次的搜索查询词,可通过绑定的历史快捷键调出上次搜索,无需重打。 2. **交替文件快速切换**:善用 Vim 原生快捷键 `Ctrl+^`(即 `Ctrl+6`),在当前文件与上一个交替文件(Alternate file)之间毫秒级跳转。 3. **光标历史跳跃**:利用 Vim 的跳转列表快捷键 `Ctrl+O` 和 `Ctrl+I`,按光标的历史停驻位置穿越回之前的编辑处。 展示全屏配置时,Alexey Samoshkin 赞叹道:“Just append a bang char to the command and have the preview window at the top this is so awesome isn't it.” --- ### [10:52](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=652s) Vim 进阶应用:文档标签、缓冲区、行检索与全文正则查找 fzf 的通用属性让它在 Vim 内部的应用延伸到了每一个角落。首先是查找 Vim 帮助文档标签(`:Helptags`)。常规使用 `:help` 时,用户脑中往往没有极其精准的标签术语,盲目尝试效率低下;而在 fzf 中输入模糊词,配合持续的试错反馈,能飞速定位到正确的帮助词条。 其次是管理已加载的缓冲区(`:Buffers`)。相比于原生敲入 `:ls` 再输入对应编号打开,使用 fzf 的 `:Buffers` 弹窗不仅支持模糊过滤,还能彻底将检索范围局限在当前已经加载进内存的文件中,在一定程度上兼任了轻量级的局部 MRU 列表。 此外,fzf 还覆盖了以下极具生产力的 Vim 场景: - **插入模式路径补全**:在编写代码或配置文件需要手写文件路径时,利用 fzf 驱动的补全,免去手动输入冗长路径的麻烦。 - **单文件内行跳转**(`:BLines`):无需用鼠标滚轮或盲目反复翻页,呼出弹窗键入关键字,直接定位到当前 Buffer 的具体代码行并精准跳转。 - **全项目内容正则搜索**(`:Rg` / `:Ag`):取代传统的全工程 grep,检索词击中后直接在 fzf 弹窗中列出命中行,并带有彩色的周边代码实时预览,选定后即可直达对应文件的目标行号。 在总结 fzf 对传统文本编辑器的赋能时,Alexey Samoshkin 评价道:“With fzf Vim can now compete with other popular text editors out there like Atom or Visual Studio Code and become more attractive option for those willing to give it a try.” | 功能场景 | 对应 Vim 命令 | 实际痛点与解决成效 | |:--- |:--- |:--- | | **项目文件查找** | `:Files` / `:Files!` | 告别 NERDTree 层层翻找,输入分散字母秒级定位文件 | | **文档检索** | `:Helptags` | 解决 `:help` 记不住官方标签的痛点,通过交互试错快速定位手册 | | **活动窗口切换** | `:Buffers` | 取代手工输入 `:ls` 与 Buffer ID,在当前打开的工作集中模糊直达 | | **单文件行定位** | `:BLines` | 告别长文件上下来回滚屏,按关键代码直接锁定行号 | | **工程全文检索** | `:Rg` | 极速全项目代码文本扫描,内置彩色上下文预览与行跳转 | ## Notable quotes > [10:52](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=652s) With fzf Vim can now compete with other popular text editors out there like Atom or Visual Studio Code and become more attractive option for those willing to give it a try. — Alexey Samoshkin > [07:18](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=438s) NERD tree is a good solution to explore an unfamiliar project but to quickly open file in a timely fashion I use fzf. — Alexey Samoshkin > [00:08](https://www.youtube.com/watch?v=qgG5Jhi_Els&t=8s) In simple terms fzf is just another Unix filter it reads whatever comes from stdin launch the interactive finder dialogue and writes the selected item to the stdout. — Alexey Samoshkin ## Mentioned Alexey Samoshkin, fzf, fzf.vim, junegunn, Vim, NERDTree, bat, fd, ripgrep, Zsh, Atom, Visual Studio Code, Sublime Text, Midnight Commander, vim-plug, SSH ## Video description Check out how to search for files with command line fuzzy finder, https://github.com/junegunn/fzf, within a shell and in a Vim. fzf is not limited to file search only, and can be used with any - ssh host names, process IDs, directories. With accompanying Vim plugin, https://github.com/junegunn/fzf.vim, we can use it to search for help tags, available commands, buffers, lines in a file, grep matches, and more. [Source](https://www.youtube.com/watch?v=qgG5Jhi_Els)

Source quotes

[10:52] Alexey Samoshkin: With fzf Vim can now compete with other popular text editors out there like Atom or Visual Studio Code and become more attractive option for those willing to give it a try. [7:18] Alexey Samoshkin: NERD tree is a good solution to explore an unfamiliar project but to quickly open file in a timely fashion I use fzf. [0:08] Alexey Samoshkin: In simple terms fzf is just another Unix filter it reads whatever comes from stdin launch the interactive finder dialogue and writes the selected item to the stdout.

Source quotes

[0:08] Alexey Samoshkin: The real advantage of fzf of a regular find command is interactive search and instant feedback.

Original transcript

[0:03] [Music] [0:08] hello everyone and today we are going to [0:10] take a look at a grade to called fzf [0:12] which stands for fuzzy finder fzf is a [0:15] general purpose common line fuzzy finder [0:17] as a definition claims but what does [0:20] that actually mean the definition is [0:22] rather succin and doesn't disclose all [0:24] wealth of the powerful capabilities it's [0:27] a very popular project rank at more than [0:29] 20,000 stars on the GitHub so it's worth [0:32] taking a deeper [0:33] Insight most people who live in a common [0:36] line environment are familiar with the [0:37] concept of Unix filters when multiple [0:39] independent utilities are composed [0:41] together into a pipeline to produce a [0:43] desired output step by step for instance [0:46] this pipeline starts with endless list [0:48] of White characters and ends up with a [0:50] list of strings in simple terms fzf is [0:53] just another Unix filter it reads [0:55] whatever comes from aadin launch the [0:58] interactive finder dialogue and wrise [1:00] the selected item to the SD out more [1:03] practical example would be searching for [1:06] files the real advantage of fzf of a [1:09] regular find command is interactive [1:11] search and instant [1:15] [Music] [1:17] feedback finding for files is so common [1:20] scenario that you can just type [1:25] fzf it supports fuzzy matching so you [1:27] can just type several characters in a [1:29] row and it will match lines with those [1:32] characters scatter it across the [1:34] stream items with exact match gets a [1:37] higher rank and as shown at the [1:39] Top If you don't like fuzzy prefix text [1:43] with a single quote or r fzf with exact [1:50] flock it doesn't support Globe patterns [1:53] so searching for start.sh would not work [1:57] but you can type multiple Search terms [2:00] limited by space match items at the [2:02] beginning or the end of the string and [2:04] negate [2:06] [Music] [2:09] matching fzf sends selected items to EST [2:12] the out which is not pretty useful [2:14] unless you pipe results somewhere next [2:17] for example you can print information on [2:19] selected [2:20] files notice how you can select multiple [2:23] items with a Tab [2:25] Key more common pattern is to take some [2:28] action on a selected file like opening [2:30] it for [2:35] editing or you can combine fzf with a [2:38] history command to search for your [2:40] recent [2:47] commands to make it more convenient [2:49] fuzzy completion can be triggered by a [2:51] dedicated sequence for instance I want [2:53] to open a single file from my do files [2:58] project but I only remember remember [3:00] part of file name and that it's [3:01] somewhere under the directory system no [3:03] need to jump back to file manager like [3:06] midnight Commander just open fuzzy [3:09] finder and here you [3:12] [Music] [3:19] go another feature I found really [3:21] helpful in changing the way I'm working [3:23] in a shell is changing a directory [3:25] before FF I were using Z shell top [3:28] completions like this [3:32] [Music] [3:35] or yet another way of typing only first [3:37] few characters of each pass [3:43] [Music] [3:46] segment well for sure that's easier than [3:49] typing a full path manually but still a [3:51] bit painful with fzf changing directory [3:54] is like a [3:56] breeze use the same sequence to trigger [3:59] fuzzy compx [4:01] while fzf is indexing directories you [4:03] can start searching get most of fuzzy [4:06] searching by typing only parts of [4:08] directory you recall best if you don't [4:11] like double star completion sequence you [4:13] can use keyboard shortcuts use contrl T [4:17] to search for files and op C to change [4:19] the [4:22] directory as stated before fzf is a [4:24] general purpose common line fuzzy finder [4:27] which means it can work with any list of [4:29] items items let's see some other useful [4:31] applications if you are a backend [4:33] developer and working with a number of [4:35] remote servers jumping back and forth [4:37] you might appreciate the fzf and SSH [4:40] combo let's jump to remote [4:44] server but turns out I forgot the right [4:47] name not an issue double starter [4:49] rescue it pulls most recently used uh IP [4:53] addresses plus host names from SSH [4:56] config and brings up the interactive [4:58] finder dialogue [5:06] [Music] [5:08] sometimes we want to send a signal to a [5:10] process but first we need to obtain its [5:12] speed usually we use P grab command to [5:15] resolve process ID by name followed by a [5:19] kill command which refers that [5:22] pit with ASF you can combine both steps [5:31] [Music] [5:34] you might be using controlr keyboard [5:36] shortcut to search through your common [5:38] history like [5:41] this that's great but how about [5:43] supercharging it with fzf like [5:49] this it pass the selected text to the [5:52] common line so you can tweak it [5:56] further interactive finder has some [5:59] extra Val features for instance you can [6:01] select multiple items with top shortcut [6:05] second you can preview items as you [6:07] search and navigate you can use any kind [6:10] of program for preview but I'm using B [6:13] for syntax highlighting and color it [6:17] output finally you can execute custom [6:20] action for example to copy past to the [6:24] [Music] [6:26] clipboard there are a lot of [6:28] configuration and customization options [6:30] so let's explore them a [6:36] bit first thing you might want to do is [6:39] to change default Fant for example to [6:41] use tools like FD or RG instead of jnu [6:50] find to change uh behavior of [6:53] interactive finder dialogue you see ifer [6:56] default Ops environment variable [7:04] so we've scratched only the basics of [7:06] fzf I would really recommend it to [7:08] anyone who working in a shell it's a [7:11] really prominent tool and has changed my [7:13] common line habits making my development [7:16] experience even more pleasant okay let's [7:18] move on in the second part of this video [7:21] we will take a look at how wiim users [7:23] can win from using fzf fzf is also [7:26] shipped as a wiim plugin install it with [7:29] a plug-in manager of your choice for [7:31] example using Wim plug once done you got [7:35] a handful of comments at your [7:40] disposal before fzf I've been using Nerf [7:43] Tre plugin to explore project structure [7:45] and navigate around but usually it takes [7:48] a while to locate the right directory [7:50] and open the file plus it makes an extra [7:53] contact switch in my mind and finally [7:55] when I open file I forgot why I need it [7:59] so [8:00] ner tree is a good solution to explore [8:02] an unfamiliar project but to quickly [8:05] open file in a timely fashion I use [8:10] fzf run files command and you would get [8:13] the very same finder interface you get [8:15] used to in a shell [8:17] environment pick up a file using fuzzy [8:20] syntax and open it by default it opens [8:23] up in a current window but you can also [8:26] open file in a split or in a new [8:34] [Music] [8:36] tab it makes sense to assign keyboard [8:39] shortcuts like contrl T or contrl P to [8:42] such a common [8:44] action personally I am using leader or [8:47] shortcut where or is for open file these [8:51] shortcuts are borrowed from other [8:53] popular text editors and IDs that are [8:56] usually shipped with fuzzy file search [8:58] and building [9:00] here is a quick look at how file search [9:02] looks like in a visual studio [9:07] [Music] [9:09] code you can preview files as you search [9:12] and navigate same as we did before in a [9:15] common line [9:18] environment for syntax highlighting and [9:20] color it output I'm using bot as a [9:22] preview command personally I've set the [9:25] finder panel height at 40% if you need [9:29] more space you can run finder in full [9:32] screen mode just append a bank Char to [9:35] the [9:36] comment and have the preview window at [9:39] the top this is so awesome isn't it here [9:43] is the relevant configuration to run a [9:47] finder in a full screen mode when suix [9:49] with a bank [9:53] symbol you can select multiple files [9:56] with top key and open all of them right [9:59] away [10:04] [Music] [10:08] the only shortcoming of fzf is it [10:10] doesn't maintain the list of most [10:11] recently used and opened files for [10:14] instance if you open files a b and a c [10:16] and a row fzf will not pull them up to [10:19] the top of the list so if you working [10:23] with a small group of files you would [10:25] find it harder to switch between them [10:27] forth and back as neither weim nor of of [10:29] Aid you you would have to search for [10:32] them again and again there are several [10:35] work rounds first fzf maintains search [10:38] history so you can use dedicated [10:41] shortcuts to get back to your recent [10:43] search second you can toggle between [10:45] current and Alternate file or use [10:48] another shortcut to jump to your [10:49] previous cursor [10:52] position recall that fzf is a general [10:55] purpose tool and it is not limited to [10:57] file search realm only time to push into [11:00] the next level and explore other [11:03] applications first let's use fzf to open [11:06] help [11:09] pag F searching isn't available here [11:13] because when I call for help most likely [11:15] I don't have clear search query ready to [11:17] go so I just open finder and look up for [11:20] the right tag with some trial and error [11:24] [Music] [11:33] with fzf you can search for any open [11:35] files called buffers instead of using a [11:38] l comment and picking up the right [11:40] buffer number to open you can use [11:49] fzf still it's not the M list but it [11:53] limits search to loaded files only as [11:56] opposite to listing all files in the [11:57] project directory [12:00] sometimes you need to type a file path [12:03] for [12:05] example you can save time with fzf power [12:08] it file type [12:12] [Music] [12:14] completion if you want to quickly jump [12:16] within a file but don't want to [12:18] continuously scroll the booer all the [12:20] way back just FF to look up Lines within [12:23] a [12:27] buffer once you made a selection it [12:30] jumps to the given [12:33] line last but not the least example is a [12:36] project wide search for lines muchart a [12:39] grab command sounds like a reasonable [12:41] use case for the fzf [12:45] tool search for a stream project white [12:48] and then you can further filter your [12:49] search in fzf finder with a nice colored [12:53] instant preview of the given [12:57] line I would recommend checking out more [13:00] ofz comments for example you can look up [13:03] through comment or search history [13:06] explore Snippets or available commments [13:09] list file types or change color [13:14] schemes I hope you impressed of how [13:16] super awesome fzf is unlock your [13:19] imagination and fit any kind of list [13:21] into it to get cool and productive fuzzy [13:23] finder for granted with fzf wiim can now [13:27] compete with other popular text editors [13:29] out there like autum or Visual Studio [13:31] code and become more attractive option [13:34] for those willing to give it a try [13:36] that's it for today thank you for [13:38] watching this video see you