How to remove all rows matching a pattern requesting permission in vi

Hello, I am new to vi, and I had a problem asking vi to ask me permission to delete the entire line with the template. My file is as follows:

SEQRES   1 A   46  GLY SER GLU ALA ARG GLU CYS VAL ASN CYS GLY ALA THR
SEQRES   2 A   46  ALA THR PRO LEU TRP ARG ARG ASP ARG THR GLY HIS TYR
SEQRES   3 A   46  LEU CYS ASN ALA CYS GLY LEU TYR HIS LYS MET ASN GLY
SEQRES   4 A   46  GLN ASN ARG PRO LEU ILE ARG

I want to delete all lines containing the string 'GLY'

This is what I came to:

:g/GLY/cd

but it is definitely wrong

+4
source share
2 answers

Only the team :substitutehas the confirm flag . However, if you use a regular expression that matches the entire line (including the trailing new line), you can use it to delete entire lines with confirmation:

:%s/.*GLY.*\n//c

:global; , Enter, Esc:

:g/GLY/if confirm('Delete: ' . getline('.')) | delete _ | endif
+3

[ :% s] , vim, : g/vim/s/.*//gc [ ] : g/^ $/d [ ]

: , vim, : /^ /s/.*// : /^ $/d

0

All Articles