Hi,
Thank you for great editor!
This is a feature request to have counts work with insert mode.
In vim counts work with insert mode in a following way:
3i=
{3ik:"v",
I could not find similar functionality in kakoune so far.
Hello,
I have thought of this feature a few times during the development of Kakoune, but it was not implemented because it did not seem useful enough. Its pretty easy to repeat the insertion with ., or copy paste. Another reason was to keep the count parameter for an eventual other use, like inserting only for a given selection.
Interestingly, pressing c with adjacent cursors gives you multiple overlapping selections (is that a bug?) so you can kinda use that to do what you propose:
10:exec ;y%val{count}p%val{count}Ls.<ret><a-space>c gives you 10 cursors.
My quoting-fu is not good enough to turn that into a usable binding though.
That's such a nice hack @occivink ! I poked around a bit with it and made it a keybinding:
def -allow-override -params 1 urk %{
exec -no-hooks \;i.<esc>hyd %arg{1} P %arg{1} Hs.<ret><a-space>c
}
map global user i %{:urk %val{count}<ret>}
@occivink Overlapping cursors are expected to work in insert mode, the main use case is c. We tend to merge the overlapping ones in normal mode though.
I ironed out some bugs (now works at end of line and undo history don't show dummy characters) and put it in one single file:
https://github.com/danr/dotfiles/blob/master/config/kak/same-point-insert.kak
I think count i should work the same way count o works at the moment, but instead of making new cursors on each line, they suppose to appear adjacent on the same line. Something similar to:
3o<esc><a-J>i
Revised snippet, courtesy of @danr
define-command -params 1 urk %{
execute-keys -with-hooks \;i.<esc>hd %arg{1} Ph %arg{1} HLs.<ret>c
}
map global user i %{:urk %val{count}<ret>}
Here's another version:
map global user i ': exec %val{count}o<lt>backspace><ret>'
Looks like it's been implemented on vis recently: https://github.com/martanne/vis/commit/4b59f95bccf66dcf7338d7180871df85d4269cf3
Most helpful comment
That's such a nice hack @occivink ! I poked around a bit with it and made it a keybinding: