I use this key mapping to duplicate a line, and go to the same cursor position on this newly created line:
nnoremap , mqYp`qj
What this does:
- Create mark 'q'
- Yank line
- Paste/put line (below current line, cursor is now at start of new line)
- Go back to mark at previous line
- Move one line down. (cursor is now on new line at the same place of start of previous line)
This works perfectly fine, however I see a flaw when putting a number in front of the command. Imagine I want to duplicate this line 10 times. It would try to create 10 marks basically. I could do Y10p
for this, I do understand that. My problem with that approach is that I'm not on the same cursor position as I was in the first line, the one I'm duplicating.
So I'm looking for a way to do basically 10,
, using my previously made mapping, and ending on the last line, at the same cursor position of where I was in the first line. Note that I am using IdeaVIM exclusively to code, which means I can't make any functions for this.
Is it possible to get this 10,
working in this situation?
Edit #1:
Example text
# Start
# Initialize new variables
new_invoice_name_one = 'New Name One'
new_invoice_name_two = 'New Name Two'
new_invoice_address_one = 'New Address One'
Command executed: 3,
with the cursor being on the first I of line 2
Desired output
# Start
# Initialize new variables
# Initialize new variables
# Initialize new variables
# Initialize new variables
new_invoice_name_one = 'New Name One'
new_invoice_name_two = 'New Name Two'
new_invoice_address_one = 'New Address One'
with the cursor being on the first I of line 5 `
Edit #2:
I see some potential at the LetHandler.java
here, however I can not seem to figure out how to use it to match the use case. On the other hand, here it says it is not supported at all.