Add word_wrap function #2

Merged
dlugowski merged 2 commits from create-function-to-wrap-word-with-characters into master 2026-08-26 17:22:59 +00:00
Showing only changes of commit c83fa13c23 - Show all commits
+18
View File
@@ -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<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).' })