New answers tagged

1 vote
Accepted

Yank list of lines into a register in vimscript

You can use the join() function to join an array to a string: let @" = getline(l:line_in, l:line_out)->join("\n") In this case, you probably want to join them by newlines as text; ...
1 vote

How can I select all non-lowercase multiline blocks which follow a keyword?

Problem 1: How :global interacts with multiline matches The main problem that you're seeing is that you're slightly misunderstanding how :global works. It doesn't run the commands on the matched text. ...
  • 29.1k
1 vote

Copy content inside brackets and the word in front of bracket (i.e. a text object for function calls)

This should work in most cases: position your cursor on the content before the opening parentheses. That is, make sure the cursor is at the beginning of whatever you want to operate one. Then <...
  • 21.9k
4 votes
Accepted

Copy content inside brackets and the word in front of bracket (i.e. a text object for function calls)

Vim only solution The simplest thing for the example you posted is probably to use visual linewise mode - va)Vwill first select the content and the surrounding parenthesis (but not the word in front) ...
  • 1,006
0 votes

Faster way to move a block of text

Edit: the below is a misunderstanding caused by assuming <cmd> in nvim is the same as :, which is not the case. Using :m '>+1<CR> does work in nvim but <cmd>m '>+1<CR> ...
  • 1
0 votes
Accepted

On Windows, putting lines with P results in the * register at the end of current line instead of the " register and shifting the current line down

My configuration is split into different files, so I renamed one at a time to disable them. When I found the file with the problem setting I commented out half of it, found the problem had gone and ...
  • 141
1 vote

Paste command to command mode instead of insert mode

Instead of using Shift-Insert to insert the marked text, use Vim registers. So first copy your line using a yank command like 0y$ and then use :CTRL-R0 to paste it into the command line. Note: ...
2 votes

How to replace line with the yanked one multiple time?

Another answer covers how to replace a line with contents of a register. However, you'll find with doing VP, you'll lose the ability to repeat it via .. I maintain a very small plugin which solves ...
  • 12.9k
1 vote

How to replace line with the yanked one multiple time?

Instead of pdd, simply select the line you want to be replaced with V and then use P. That's it. The reason to use the upper-case P instead of p is that it preserves registers, allowing you to do the ...
2 votes

How to replace line with the yanked one multiple time?

Assuming you grabbed the first line with a y command, it should be in register 0. So you can do "0pdd every time (or, let @q = '"0pdd' and run @q/@@ for slightly less typing). If the target ...
  • 21.9k

Top 50 recent answers are included