Skip to content

Commit

Permalink
better p
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Mar 30, 2024
1 parent 49f5c16 commit c114fd7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/keymap/remap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ map.n({

-- paste with correct indent
map.n('p', function()
vim.cmd('normal! p==')
local text = vim.fn.getreg('"')
-- if have mulitple \n assume before copy from the visual mode
local count = #vim.split(text, '\n', { trimempty = true })
vim.cmd('normal! ' .. ('p%s'):format((count == 1 and '==' or ('v%sj=='):format(count))))
end, { remap = true })

map.i({
Expand Down

0 comments on commit c114fd7

Please sign in to comment.