Donncha writes:
> Just deleted some lines in a file and discovered this nugget which
> someone might find handy..
> Search for a word using the usual "/" way.
> Then, in command mode, press "d" to delete and type "/<RETURN>" and
> it'll delete to the next occurance of the previous searched for word..
> Of course, you could do "d", and then "/searchword" to delete from the
> current position to position of "searchword" too which is much the same.
> Makes sense since you can do dw,db,dk, etc..
Actually, this is part of a *really* powerful vi feature. You can
follow 'd' by *any* movement command and it'll delete the range covered
- between the point you start at and the point you end at.
Examples :
dG delete from here to the end of the file
d1G delete from here to the start of the file
d} delete from here to the end of the paragraph
d5w delete 5 words
d20h delete 20 characters to the left
d/echo<RET> delete to the next occurrence of the word 'echo'
This also works for the 'y' command (yank) - 'd' is to 'cut' what 'y' is
to 'copy'.
vi is a *very* powerful editor; a lot more so than people give it credit
for.
Colm
--
Colm Buckley BA BF | NewWorld Commerce, 44 Westland Row, Dublin 2, Ireland
colm at tuatha.org (personal) | colm.buckley at nwcgroup.com (business)
+353 87 2469146 | whois cb3765 | http://www.tuatha.org/~colm/
Can open. Worms everywhere.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!