Autonomía digital y tecnológica

Código e ideas para una internet distribuida

Linkoteca. Navigation archive


Search and replace or delete multiples lines in vim

The :global command is your friend – learn it well. It lets you run arbitrary :ex commands on every line that matches a regex. It abbreviates to :g.

To delete all lines that match “George Bush”:

:g/George Bush/ d

The command that follows can have its own address/range prefix, which will be relative to the matched line. So to delete the 5th line after George Bush:

:g/George Bush/ .+5 d

To delete the DEBUG log entries:

:g/DEBUG/ .,+10 d

Dejar un comentario

No hay comentarios en esta entrada.
*
*

 

No hay trackbacks