From c83fa13c2348f1795c14182cddba279fa0561b11 Mon Sep 17 00:00:00 2001 From: Derek Lugowski Date: Wed, 26 Aug 2026 17:17:13 +0000 Subject: [PATCH] Add word_wrap function --- wrap_word.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 wrap_word.lua diff --git a/wrap_word.lua b/wrap_word.lua new file mode 100644 index 0000000..63c669e --- /dev/null +++ b/wrap_word.lua @@ -0,0 +1,18 @@ +local function wrap_word() + local param = vim.fn.input 'Enter char(s) to wrap word: ' + if param == '' then + return + end + + local num_spaces_to_move = #param - 1 + local move_cmd = '' + if num_spaces_to_move > 0 then + move_cmd = num_spaces_to_move .. 'h' + end + + local cmd = string.format('ciw%s%s%sP', param, param, move_cmd) + + vim.cmd('normal! ' .. vim.api.nvim_replace_termcodes(cmd, true, true, true)) +end + +vim.keymap.set('n', 'ww', wrap_word, { desc = '[W]rap [W]ord with character(s).' }) \ No newline at end of file