Vi, replace text -


i have text this

template template template_results template 

and need replace this

template_form template_form template_results template_form 

how can replace every match of template not followed _ character in vi?

i tried this

:%s/template[^_]/template_form    - pattern not found :%s/template\[^_]/template_form   - pattern not found :%s/template[_]/template_form     - works, pattern opposite of need 

thank :)

use negative lookahead:

:%s/template\(_\)\@!/template_form/gc 

this means match "template" not followed (\@!) "_"

see: :help /zero-width


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -