Reputation: 16974
Every now and then I run into this type of editing problem in Vim.
I have text formatting in a table that I want to turn into a list.
Before:
AAA BBB
AAA BBB
AAA BBB
CCC DDD
CCC DDD
CCC DDD
After:
AAA
AAA
AAA
BBB
BBB
BBB
CCC
CCC
CCC
DDD
DDD
DDD
Of course not as trivial as this example. The blocks can have hairier contents, larger and inconsistent numbers of lines, etc.
The way I do it now seems to be a bit of a hack:
CTRL-q
in the Windows version to select the top-left corner.d
to cut the block.SHIFT+p
to paste the block into this area.Step is the rough part.
Doing a normal non-block cut or copy will always paste into "new" lines. A kind of "insert" or "append" operation. Doing a block cut or copy will normally paste in a kind of "overwrite" mode.
Is there a better way to copy or cut in "block mode" but paste in "insert / append mode"?
Upvotes: 8
Views: 849
Reputation: 45117
The ex command :put
will always paste a register line wise.
Cut the block of text with visual block mode like you have before then execute :put
instead of p
.
If you want to "cast" pastes in more ways then use @Ingo Karkat's plugin.
For more information see:
:h pu
Upvotes: 8
Reputation: 195069
you can block wise select the BBB
part as how you did, and after cut by d
for example, you run this command:
call setreg('"',@",'V')
then you can paste to target line, it will turn your block-wise "yank" into line-wise.
You can create a mapping if you do need to do this often.
Upvotes: 2
Reputation: 172590
My UnconditionalPaste plugin has a glp
(go linewise paste) command that will paste the register contents as new lines, regardless of how they were yanked (e.g. in blockwise mode).
It also has several other helpful commands that affect the way the register is pasted.
Upvotes: 1