copy filename shortcut
parent
d45101d38d
commit
33487db7c3
|
@ -14,6 +14,8 @@ keymap.set('n', '<leader>tp', ':tabp<CR>', { silent = true }) -- go to prev
|
|||
keymap.set('n', 'gn', ':bn<CR>', { silent = true })
|
||||
keymap.set('n', 'gp', ':bp<CR>', { silent = true })
|
||||
keymap.set('n', 'g[', ':b#<CR>', { silent = true })
|
||||
-- copy filename in buffer
|
||||
keymap.set('n', '<leader>cf', ':let @+ = expand("%:t")<CR>', { silent = true })
|
||||
|
||||
-- keymap.set('n', '<C-s>', ':w<CR>')
|
||||
keymap.set('n', '<leader>x', ':bd<CR>', { silent = true })
|
||||
|
@ -72,18 +74,18 @@ keymap.set('n', '<leader>fh', '<cmd>Telescope file_history history<CR>', { silen
|
|||
|
||||
-- Define a custom function to move the current buffer to a vertical split with the previous buffer
|
||||
function move_to_vertical_split()
|
||||
local current_buffer = vim.fn.bufnr('%') -- Get the current buffer number
|
||||
local last_buffer = vim.fn.bufnr('#') -- Get the previous buffer number
|
||||
local current_buffer = vim.fn.bufnr('%') -- Get the current buffer number
|
||||
local last_buffer = vim.fn.bufnr('#') -- Get the previous buffer number
|
||||
|
||||
-- Check if last_buffer is set; if not, duplicate the current buffer
|
||||
if last_buffer == -1 then
|
||||
vim.cmd('vsplit')
|
||||
vim.cmd('b ' .. current_buffer)
|
||||
else
|
||||
vim.cmd('vsplit')
|
||||
vim.cmd('b ' .. last_buffer)
|
||||
vim.cmd('wincmd w') -- Switch focus to the original (current) buffer
|
||||
end
|
||||
-- Check if last_buffer is set; if not, duplicate the current buffer
|
||||
if last_buffer == -1 then
|
||||
vim.cmd('vsplit')
|
||||
vim.cmd('b ' .. current_buffer)
|
||||
else
|
||||
vim.cmd('vsplit')
|
||||
vim.cmd('b ' .. last_buffer)
|
||||
vim.cmd('wincmd w') -- Switch focus to the original (current) buffer
|
||||
end
|
||||
end
|
||||
|
||||
-- Map <leader>v to the custom function
|
||||
|
@ -93,12 +95,12 @@ keymap.set('n', '<leader>v', [[:lua move_to_vertical_split()<CR>]], { noremap =
|
|||
keymap.set("n", "<F2>", '<cmd>Telescope persisted<CR>', { silent = true })
|
||||
|
||||
keymap.set("n", "<leader>m", function()
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
local wininfo = vim.fn.getwininfo(winid)[1]
|
||||
local winid = vim.api.nvim_get_current_win()
|
||||
local wininfo = vim.fn.getwininfo(winid)[1]
|
||||
|
||||
if wininfo and wininfo.wincol > vim.o.columns / 2 then
|
||||
vim.cmd("wincmd H") -- Move to the left if currently on the right
|
||||
else
|
||||
vim.cmd("wincmd L") -- Move to the right if currently on the left
|
||||
end
|
||||
if wininfo and wininfo.wincol > vim.o.columns / 2 then
|
||||
vim.cmd("wincmd H") -- Move to the left if currently on the right
|
||||
else
|
||||
vim.cmd("wincmd L") -- Move to the right if currently on the left
|
||||
end
|
||||
end, { desc = "Move buffer between left/right split" })
|
||||
|
|
Loading…
Reference in New Issue