martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.23k stars 256 forks source link

How to perform an append write #866

Closed 7m0E7TRWiyc7eJlETAgDR-rp6HLJf2yvSnJLuQL closed 3 years ago

7m0E7TRWiyc7eJlETAgDR-rp6HLJf2yvSnJLuQL commented 4 years ago

Is there a way of duplicating vim for an append write: :w >> filename

ninewise commented 4 years ago

Not directly.

But you could always ggyG to yank the whole file, :split filename to open that one, GP to paste it at the end, and w to write it?

7m0E7TRWiyc7eJlETAgDR-rp6HLJf2yvSnJLuQL commented 4 years ago

I worked out a way to do it, although I have no idea why it works as I didn't see it in the documentation, but: :+.> cat >> filename I'm sure someone can explain it to me, but for what ever reason, it works on any line I choose except for the first one. The :.> cat >> was found in a different comment here, but adding the + is what made it work for me.

ninewise commented 4 years ago

Hm, that ought to append the current line to the file. +. will just keep the current selection, and > cat >> filename will pipe (the lines of) the current selection to the cat >> filename command, which will append this.

What should be the working thing (if you don't mind cat) is :,> cat >> filename. , means the entire file.

martanne commented 3 years ago

The explanation of @ninewise is correct.