Effortless Folder Jumping in Vim
In this blog post, I introduce a new Vim9script plugin that provides quick access to the ten most latest updated directories, including the ability to restore session files. This plugin can be installed with a plugin manager (such as Plug) from this GitHub repository:
https://github.com/sevehub/recentdirs.vim
Once installed, it adds the keybinding leaderfD to view a list of 10 selectable directories from the current location that contain files that have been recently modified.
By selecting a location from this list, Vim changes its current working directory to the chosen one.
This plugin populates a global variable with recently accessed folders, which can be displayed in a fuzzy finder popup using a second plugin described at this link, and mapped to leaderfd.
At the top of the list, as shown in the video below, it places the bookmarked directories saved by Netrw in the file .netrwbook
, while the remaining folders are extracted from the viminfo.
Vim Sessions
Vim sessions are a powerful feature that allows users to save the current state of their editing environment, making it easy to resume work later. By using the :mksession
command, you can save your open files, window layouts, and modified settings to a session file, typically named Session.vim
. This functionality is particularly useful for managing complex projects, as it enables you to pause your work and return to it without losing context.
To enhance the session management experience, the plugin Vim-Obsession can be utilized. This plugin automates the process of saving sessions, allowing you to focus on your work without worrying about manually saving your environment. With Vim-Obsession, sessions are automatically saved when you exit Vim, ensuring that your workspace is always preserved.
Additionally, the status of Vim-Obsession, whether enabled or paused, can be displayed in the statusline, providing you with a clear indication of your session management status. Below and example:
let g:airline_section_y='%{airline#util#wrap(airline#parts#ffenc(),0)}|%{ObsessionStatus("S","$")}|%{&shell}'
Furthermore, the plugin fdminifuzzy facilitates the sourcing of Session.vim
when jumping to a folder that contains this configuration file, streamlining the process of restoring your editing environment.