History Jumper is a plugin for Neovim that allows you to quickly jump to previously opened files using just three keystrokes. It is a great productivity tool for developers who work with multiple files simultaneously.
You can install History Jumper using your favorite plugin manager. Here's an example using lazy.nvim:
return {
'zzhirong/history-jumper.nvim',
config = function()
require'history-jumper'.setup({
prefix = '|', -- Like a door to oldfiles
change_dir = true, -- Will change to the dir of the file; if there is a git repository, then it will change the directory to the directory containing the .git
})
end
}
Make sure to also have fzf.vim installed.
2023-4-17 Update: remove dependencie of fzf.vim
.
You can customize the key mapping for History Jumper by setting the prefix
option in the configuration.
To jump to a previously opened file, input three keystrokes: prefix
+ the first letter of the last path portion
+ the first letter of the file name
.
For example, to jump to history-jumper/lua/init.lua
:
- The first key is
prefix
, which was assigned in the configuration (default isS
). - The last path portion is
lua
, so the second letter isl
. Once you press the second letter, a floating window will appear with a list of candidates for selection. You can press<Esc>
to abort the selection. - The file name is
init.lua
, the first letter of the file name, which isi
,- If there is only one left with filename starts with
i
, then the third letter isi
. - If there are multiple files with names starting with
i
, this plugin will assign a number index next to the first one, so the third key may be a number.
- If there is only one left with filename starts with
So the final key to switch to history-jumper/lua/init.lua
is Sli
or sl[0-9]
.