Add word_wrap function
This commit is contained in:
@@ -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).' })
|
||||
Reference in New Issue
Block a user