Skip to content

Visual Studio Code plugin that makes it easy to work with files across the entire file system

License

Notifications You must be signed in to change notification settings

mogelbrod/quick-opener

Repository files navigation

Quick Opener for Visual Studio Code

A plugin that makes it easy to open files outside the VS Code workspace (or relative to the current file) using a quick pick window.

Animated example

Features

Keybindings on Mac use in place of Ctrl.

  • Show the Quick Opener picker by pressing Ctrl-O
  • Open any path across the file system using only the keyboard (no more pesky native file system popups!)
  • Fuzzy path matching using the built-in VS Code fuzzy matcher
  • Starts in directory of current file (if open) to make relative navigation quick and easy
  • Begin entering any absolute path (or a pre-configured prefix) to quickly locate files outside the current workspace
  • Navigate to parent directory by entering .. or pressing Ctrl-U
  • Additional functionality available via window and item buttons, as well as keybindings:
    • Enter - File: Open file / Directory: Change relative root directory
    • Ctrl-O - File: Open in split / Directory: Add/remove directory to/from workspace
    • Ctrl-Shift-O - Directory: Open directory in new window
    • Ctrl-U - Cut off last part of the input path / navigate to parent directory
    • Ctrl-N - Create new file (or directory if input ends with a slash) at the given path, with ancestor directories created in the process
    • Tab - Replace input value with selected item

Installation

  1. Navigate to the Quick Opener extension page within VS Code by either:
  2. Press the corresponding Install button

Extension contributions

Key bindings

The default behaviour of the plugin is to take over the standard key binding to open a file/folder: Ctrl-O (Mac: -O).

If you wish to use another key binding you can append the following to keybindings.json:

  {
    "key": "cmd+o", // Revert the binding back to the editor default
    "command": "-quickOpener.show"
  },
  {
    "key": "cmd+shift+o", // New binding to use
    "command": "quickOpener.show"
  },

Custom key bindings

Example of how to define custom key bindings:

  {
    "when": "inQuickOpener", // limit binding to when plugin is visible
    "command": "quickOpener.triggerItemAction",
    "args": 1, // trigger first visible action for item (depends on item type)
    // "args": 2, // OR trigger second visible action for item (depends on item type)
    "key": "ctrl+shift+o",
  },
  {
    "when": "inQuickOpener",
    "command": "quickOpener.triggerAction",
    "args": ["create"], // create file/directory
    "key": "ctrl+n",
  }

Settings

  • quickOpener.fallbackDirectory: Directory to start in when there's no workspace/file open in the editor. Supports vscode variables.
    Default value: "${userHome}"
  • quickOpener.prefixes: Mapping of path prefixes to their expanded paths. A path starting with any of these strings followed by a directory separator will be expanded to the corresponding path. Supports vscode variables.
    Default value: { "~": "${userHome}", "@": "${workspaceFolder}" }
  • quickOpener.exclude: List of directory/file names to exclude from the results. Compared against the name of each path component.
    Default value: ["node_modules", ".git", ".DS_Store"]
  • quickOpener.timeout: Maximum time (in ms) for scanner to run between input and showing results. Set to 0 to disable recursive search.
    Default value: 200
  • quickOpener.maxCandidates: Maximum number of paths to include in the list VS Code fuzzy matches against. Lower values improve UI responsiveness at the risk of fewer nested directories being included in the list.
    Default value: 10000

Commands

  • quickOpener.show: Show the Quick Opener picker.

Commands available while the plugin window is visible:

  • quickOpener.popPath: Go upwards in the path by chopping off the last part of the input (if present), or by navigating to parent directory.
  • quickOpener.triggerAction: Trigger an action using the current input as path.
  • quickOpener.triggerItemAction: Trigger an action using the currently selected item as path.
  • quickOpener.triggerTabCompletion: Replace the input value with the selected item path.

Disclaimer

The Create directory/file functionality will attempt to create directories when necessary. This should not cause any data to be lost or overwritten, but I can unfortunately not guarantee that it will never happen in every possible situation.

Credits

  • Icon: Created with the assistance of DALL·E 2