diff --git a/docs/faq.md b/docs/faq.md index e4205c9f..e028fb70 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -74,11 +74,11 @@ The decision to separate `enter` and `open` commands was intentional. Yazi will be adding the ability to treat an archive as a directory in the future, allowing direct operations on the files inside. -An archive is a file, so it's "openable", but it's also "enterable" as a directory; so the user can choose the action they want to perform. +An archive is a file, so it's "openable", but it's also "enterable" as a directory; so the user can choose the action they want to do. This is true for a actual directory as well - a directory can be entered (in Yazi), or opened (in programs like VSCode or desktop file managers). -If you truly don't need to distinguish between them, the upcoming Yazi plugin system will also assist you. It will allow you to implement the behaviors you want through plugins. +If you truly don't need to distinguish between them, use this [smart-enter tip](/docs/tips.md#smart-enter-enter-for-directory-open-for-file). ## Why is "orphan" set to false by default? diff --git a/docs/tips.md b/docs/tips.md index 0424ca44..04473dce 100644 --- a/docs/tips.md +++ b/docs/tips.md @@ -90,6 +90,25 @@ You can change the `` of input component from the default `escape` to `clos To exiting input directly, without entering Vi mode, making it behave like a regular input box. +## Smart enter: `enter` for directory, `open` for file + +Save those lines as `~/.config/yazi/plugins/smart-enter.yazi/init.lua`: + +```lua +return { + entry = function() + local h = cx.active.current.hovered + ya.manager_emit(h and h.cha.is_dir and "enter" or "open", {}) + end, +} +``` + +Then bind it for `l` key, in your `keymap.toml`: + +```toml +{ on = [ "l" ], exec = "plugin --sync smart-enter", desc = "Enter the child directory, or open the file" }, +``` + ## Drag and drop via [`dragon`](https://github.com/mwh/dragon) Original post: https://github.com/sxyazi/yazi/discussions/327