Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range (count) with insert #1106

Open
zaript opened this issue Jan 3, 2017 · 8 comments

Comments

@zaript
Copy link

commented Jan 3, 2017

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= will produce === which is convenient for markdown headers.
{3ik:"v", i} will produce {k:"v", k:"v", k:"v"} which is an easy way to initiate a set.

I could not find similar functionality in kakoune so far.

@mawww

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2017

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.

@occivink

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

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.

@danr

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

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>}
@mawww

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2017

@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.

@danr

This comment has been minimized.

Copy link
Contributor

commented Jan 29, 2017

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

@vbauerster

This comment has been minimized.

Copy link
Contributor

commented May 24, 2019

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
@vbauerster

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2019

Revised snippet, courtesy of @danr

define-command -params 1 urk %{
    execute-keys -with-hooks \;i.<esc>hd %arg{1} P %arg{1} Hs.<ret><a-space>c
}
map global user i %{:urk %val{count}<ret>}
@danr

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

Here's another version:

map global user i ': exec %val{count}o<lt>backspace><ret>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.