@ -51,6 +51,38 @@ map("n", "<leader>/", function()
require ( " Comment.api " ) . toggle.linewise . current ( )
end , { desc = " comment toggle " } )
--Move line
local function move_line ( op )
return function ( )
local start = op == " + " and 1 or 2
local count = vim.v . count
local times = count == 0 and start or ( op == " + " and count or count + 1 )
local ok , _ = pcall ( vim.cmd . move , op .. times )
if ok then
vim.cmd . norm ( " == " )
end
end
end
local function move_selected ( op )
return function ( )
local restore_autocmd = u.disable_autocmd ( " toggle_relnum " )
local start = op == " + " and " " or 2
local count = vim.v . count
local times = count == 0 and start or ( op == " + " and count or count + 1 )
local mark = op == " + " and " '> " or " '< "
vim.api . nvim_feedkeys ( vim.keycode ( " :move " .. mark .. op .. times .. " <Cr>gv=gv " ) , " n " , true )
restore_autocmd ( )
end
end
map ( " n " , " <A-j> " , move_line ( " + " ) , { silent = true , desc = " Move line to Top " } )
map ( " n " , " <A-k> " , move_line ( " - " ) , { silent = true , desc = " Move line to Down " } )
map ( " x " , " <A-j> " , move_selected ( " + " ) , { silent = true , desc = " Move Group of line to Top " } )
map ( " x " , " <A-k> " , move_selected ( " - " ) , { silent = true , desc = " Move Group of line to Down " } )
map (
" v " ,
" <leader>/ " ,