diff --git a/README.md b/README.md index 05e93eee..b78511bd 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,9 @@ These are the default keybindings that are available when yazi is open: - ``: open the selected file in a vertical split - ``: open the selected file in a horizontal split +- ``: open the selected file in a new tab + +Notice that these are also the defaults for telescope. ## About my fork @@ -110,5 +113,6 @@ So far I have done some maintenance work and added a bunch of features: - feat: can send multiple opened files to the quickfix list - feat: can open a file in a vertical split - feat: can open a file in a horizontal split +- feat: can open a file in a new tab If you'd like to collaborate, contact me via GitHub issues. diff --git a/lua/yazi/config.lua b/lua/yazi/config.lua index 3b41e5f3..2ae92ae6 100644 --- a/lua/yazi/config.lua +++ b/lua/yazi/config.lua @@ -33,6 +33,11 @@ function M.default_set_keymappings_function(yazi_buffer, config) config.open_file_function = openers.open_file_in_horizontal_split M.select_current_file_and_close_yazi() end, { buffer = yazi_buffer }) + + vim.keymap.set({ 't' }, '', function() + config.open_file_function = openers.open_file_in_tab + M.select_current_file_and_close_yazi() + end, { buffer = yazi_buffer }) end -- This is a utility function that can be used in the set_keymappings_function diff --git a/lua/yazi/openers.lua b/lua/yazi/openers.lua index 0bd12a37..4b706cb1 100644 --- a/lua/yazi/openers.lua +++ b/lua/yazi/openers.lua @@ -13,6 +13,10 @@ function M.open_file_in_horizontal_split(chosen_file) vim.cmd(string.format('split %s', chosen_file)) end +function M.open_file_in_tab(chosen_file) + vim.cmd(string.format('tabedit %s', chosen_file)) +end + ---@param chosen_files string[] function M.send_files_to_quickfix_list(chosen_files) vim.fn.setqflist({}, 'r', {