You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- my_utils.lualocalM= {}
-- starting at cursor: overwrite text to right with register content-- keep_suffix defines, if remaining line suffix should be keptM.pasteOverwriteFromRegister=function(register, keep_suffix)
localline_content=vim.api.nvim_get_current_line()
localreg_content=vim.fn.getreg(register)
localtup_rowcol=vim.api.nvim_win_get_cursor(0) -- [1],[2] = y,x = row,collocalcol_nr=tup_rowcol[2] -- 0 indexed => use +1localcol=col_nr+1localreg_len=string.len(reg_content)
localline_len=string.len(line_content)
localprefix=string.sub(line_content, 1, col-1) -- until before cursorlocalsuffix=string.sub(line_content, col+reg_len, line_len) -- starting at cursorifkeep_suffix==truethenvim.api.nvim_set_current_line(prefix..reg_content..suffix)
elsevim.api.nvim_set_current_line(prefix..reg_content)
endendreturnM
-- my_keymaps.lua-- suggested keymapingslocalopts= { noremap=true, silent=true }
localmap=vim.api.nvim_set_keymapmap('n', '<leader>p', [[<cmd> lua require("my_utils").pasteOverwriteFromRegister('+', true)<CR>]], opts)
map('n', '<leader>P', [[<cmd> lua require("my_utils").pasteOverwriteFromRegister('+', false)<CR>]], opts) -- replacement for broken [[v$P]]map('n', '<C-p>', 'p`[', opts) -- ] paste without cursor movementmap('n', ',', [[viwP]], opts) -- keep pasting over the same thing for current word, simple instead of broken for EOL [["_diwP]]
Opinions?
The text was updated successfully, but these errors were encountered:
matu3ba
changed the title
all the simple ways of "keep pasting" (without cursor movement, word replace, memset, memset + trunace until EOL)
all the simple ways of "keep pasting" (without cursor movement, word replace, memset, memset + truncate until EOL)
Jan 28, 2023
matu3ba
changed the title
all the simple ways of "keep pasting" (without cursor movement, word replace, memset, memset + truncate until EOL)
all the simple ways of "keep pasting" (without cursor movement, word replace, strcpy, strcpy + truncate until EOL)
Jan 28, 2023
Opinions?
The text was updated successfully, but these errors were encountered: