Added Moving Lines Up and Down in Vim without Using the Clipboard
https://www.youtube.com/watch?v=gNyNm5DsQ88
This commit is contained in:
parent
a15b0cebdd
commit
8f8880851e
41
init.lua
41
init.lua
|
|
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
@ -180,10 +180,10 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
|
||||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||||
|
|
||||||
-- TIP: Disable arrow keys in normal mode
|
-- TIP: Disable arrow keys in normal mode
|
||||||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
||||||
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
||||||
|
|
||||||
-- Keybinds to make split navigation easier.
|
-- Keybinds to make split navigation easier.
|
||||||
-- Use CTRL+<hjkl> to switch between windows
|
-- Use CTRL+<hjkl> to switch between windows
|
||||||
|
|
@ -200,6 +200,34 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
|
||||||
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
|
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
|
||||||
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
|
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
|
||||||
|
|
||||||
|
-- NOTE: Francis Custom block mover:
|
||||||
|
-- Alt J / K in visual mode to more a block up/down
|
||||||
|
-- Try to move lines up/down in normal and visual modes
|
||||||
|
|
||||||
|
-- Helper function to safely map keys
|
||||||
|
local function map(mode, lhs, rhs, opts)
|
||||||
|
local options = { noremap = true, silent = true }
|
||||||
|
if opts then
|
||||||
|
options = vim.tbl_extend('force', options, opts)
|
||||||
|
end
|
||||||
|
vim.keymap.set(mode, lhs, rhs, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Helper function to safely map keys
|
||||||
|
local function map(mode, lhs, rhs, opts)
|
||||||
|
local options = { noremap = true, silent = true }
|
||||||
|
if opts then
|
||||||
|
options = vim.tbl_extend('force', options, opts)
|
||||||
|
end
|
||||||
|
vim.keymap.set(mode, lhs, rhs, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Move lines with Cmd+j / Cmd+k
|
||||||
|
map('n', '<D-j>', ':m .+1<CR>==', { desc = 'Move line down (Cmd)' })
|
||||||
|
map('n', '<D-k>', ':m .-2<CR>==', { desc = 'Move line up (Cmd)' })
|
||||||
|
map('v', '<D-j>', ":m '>+1<CR>gv=gv", { desc = 'Move selection down (Cmd)' })
|
||||||
|
map('v', '<D-k>', ":m '<-2<CR>gv=gv", { desc = 'Move selection up (Cmd)' })
|
||||||
|
|
||||||
-- [[ Basic Autocommands ]]
|
-- [[ Basic Autocommands ]]
|
||||||
-- See `:help lua-guide-autocommands`
|
-- See `:help lua-guide-autocommands`
|
||||||
|
|
||||||
|
|
@ -886,7 +914,8 @@ require('lazy').setup({
|
||||||
-- Load the colorscheme here.
|
-- Load the colorscheme here.
|
||||||
-- Like many other themes, this one has different styles, and you could load
|
-- Like many other themes, this one has different styles, and you could load
|
||||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
-- vim.cmd.colorscheme 'tokyonight-night'
|
||||||
|
vim.cmd.colorscheme 'default'
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue