File History Navigation
Browser-style Back and Forward navigation between files for VSCodium and Visual Studio Code (VS Code).
Why this extension exists
VS Code's built-in Go Back and Go Forward commands use a location-based history that also records navigation within a file, such as mouse clicks and jumps to a specific function or code line.
For example, you navigate:
README.md
|
V
example.js (line 50 is active)
|
V
example.js (line 100 is active after clicking it)
If you now select Go Back, VS Code takes you back to line 50 of example.js. That is not how a browser behaves when you select its Back button. I wanted a Go Back command that takes me directly back to README.md, the previous file.
Features
- Keeps a separate file history for each editor group.
- Records file changes only, not cursor movement, selections, scrolling, or other navigation within a file.
- Tracks text and notebook diff views, reopening both sides of the diff during navigation.
- Discards forward history after opening a different file following Back navigation.
Commands
Use these commands:
File History Navigation: BackFile History Navigation: Forward
To run a command, open the Command Palette with Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows and Linux, search for file history, and select the command.
To assign a shortcut, open Keyboard Shortcuts with Cmd+K Cmd+S on macOS or Ctrl+K Ctrl+S on Windows and Linux. Search for file history, double-click the command's Keybinding column, press the preferred key combination, and press Enter to save it.
Alternatively, run Preferences: Open Keyboard Shortcuts (JSON) from the Command Palette and add these entries to the array in keybindings.json. Replace the sample key combinations with your preferred shortcuts:
[
{
"key": "ctrl+alt+left",
"command": "CodingMarkus.file-history-navigation.back"
},
{
"key": "ctrl+alt+right",
"command": "CodingMarkus.file-history-navigation.forward"
}
]
The extension does not assign default keyboard shortcuts, pick whatever feels appropriate to you.
Settings
Change the maximum number of history entries per editor group in Settings by searching for file history. The default is 50.
You can also set CodingMarkus.file-history-navigation.maxEntries in settings.json:
"CodingMarkus.file-history-navigation.maxEntries": 50
Compatibility
Compatible with VS Code and VSCodium.
Files reopen using their registered editor, including custom, notebook, and binary editors.
Download
Download the extension from Codeberg, Open VSX, or the Visual Studio Marketplace.
See the release history.
Development
See the development instructions.
License
MIT, see LICENSE.
My other projects
See also my other projects.