Files
dlugowski bbf1e3d1c2 Add word_wrap function and keybind
Creates a word_wrap function and keybind.

Keybind: <leader>ww

Allows you to type any characters you want, and the currently highlighted word will be wrapped with those characters.

Works on #1
Reviewed-on: #2
2026-08-26 17:22:58 +00:00

18 lines
517 B
Lua

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<ESC>%sP', param, param, move_cmd)
vim.cmd('normal! ' .. vim.api.nvim_replace_termcodes(cmd, true, true, true))
end
vim.keymap.set('n', '<leader>ww', wrap_word, { desc = '[W]rap [W]ord with character(s).' })