Select the data inserted by the `!` and `<a-!>` primitives
lenormf opened this issue · 3 comments
Hi,
It would be convenient to have the text inserted by the !
and <a-!>
primitives automatically selected after they've been added to the buffer.
Thanks.
Yes. And I think this approach could be generalized.
Current situation:
p
andP
inserts/appends the content of a register but keeps the selection<a-p>
and<a-P>
inserts/appends every yanked selections and select each pasted string!
and<a-!>
inserts/appends a shell command output
Notice that only <a-p>
/<a-P>
have the behavior of selecting what's been inserted. It does 2 things.
As lenormf request in this issue, this "insert AND select inserted" behavior could be useful for !
and <a-!>
, but I'll argue that it can sometimes also be useful for regular p
and P
as well.
So I think we should be consistent everywhere:
- make
<a-p>
and<a-P>
only insert/append. - offer an easy way to select what's just been inserted if desired.
Potential suggestion could be to store a %val{inserted_selections_desc}
that is refreshed everytime one of the p or ! commands above are triggered. This way the user could add a map in his kakrc:
map global user s ':select %val{inserted_selections_desc}`
Code wise I think it should be possible because the third param of selection.insert()
already provides the inserted selections like in the paste_all
funcition: https://github.com/mawww/kakoune/blob/master/src/normal.cc#L701
Potential suggestion could be to store a
%val{inserted_selections_desc}
that is refreshed everytime one of thep
or!
commands above are triggered
vim/neovim has the '[
and ']
marks: https://neovim.io/doc/user/motion.html#'[ that delimit the beginning and the end of pasted text.
These marks are the foundation if this text-object: https://github.com/saaguero/vim-textobj-pastedtext
Can we set the selection orientation to the left for <a-!>
, so we can press h
after the command to return to the previous position.