From a3f56c03b47c7206b10bdb70aa2c1b9efd0ee0c4 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 16 Dec 2024 17:38:30 -0500 Subject: [PATCH] commit: 2024-12-16 17:38:30 --- lua/mappings.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/mappings.lua b/lua/mappings.lua index 267bc02..85294d7 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -57,3 +57,15 @@ vim.cmd('set shiftwidth=4') vim.cmd('set expandtab') vim.o.hidden = true + +-- wrap selected text in single quotes +vim.keymap.set('x', "'", function() + local text = vim.fn.getreg('"') -- Get the visually selected text + vim.cmd("normal! c'" .. text .. "'") +end, { desc = "Wrap selected text in single quotes" }) + +-- wrap selected text in double quotes +vim.keymap.set('x', '"', function() + local text = vim.fn.getreg('"') -- Get the visually selected text + vim.cmd('normal! c"' .. text .. '"') +end, { desc = "Wrap selected text in double quotes" })