vim - how to delete all lines that match a pattern asking permission in vi -


hello i'm new vi , have problem making vi ask me permission delete line pattern. file looks this:

seqres   1   46  gly ser glu ala arg glu cys val asn cys gly ala thr seqres   2   46  ala thr pro leu trp arg arg asp arg thr gly tyr seqres   3   46  leu cys asn ala cys gly leu tyr lys met asn gly seqres   4   46  gln asn arg pro leu ile arg 

i want delete lines contain string 'gly'

this came to:

:g/gly/cd 

but it's wrong

only :substitute command has confirm flag. however, if use regular expression matches entire line (including trailing newline), can use delete entire lines, confirmation:

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

alternatively, build own confirmation :global; here's simple 1 have answer either enter or esc:

:g/gly/if confirm('delete: ' . getline('.')) | delete _ | endif 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -