Skip to content

Commit

Permalink
feat: allow opening the selected file in a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Apr 13, 2024
1 parent 6ae9144 commit e4c5532
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ These are the default keybindings that are available when yazi is open:

- `<c-v>`: open the selected file in a vertical split
- `<c-s>`: open the selected file in a horizontal split
- `<c-t>`: open the selected file in a new tab

Notice that these are also the defaults for telescope.

## About my fork

Expand All @@ -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.
5 changes: 5 additions & 0 deletions lua/yazi/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' }, '<c-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
Expand Down
4 changes: 4 additions & 0 deletions lua/yazi/openers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit e4c5532

Please sign in to comment.