VIM replacing text in 2 columns -


so below part of 1 column-sensitive file lines 23 34. please @ columns 25 , 26. lines 23 28 correct it's supposed sequential.

hetatm   21  o   hoh     7      -1.609   5.551  -4.296  1.00  0.00      wat  o hetatm   22  h   hoh     7      -1.594   5.971  -3.395  1.00  0.00      wat  h hetatm   23  h   hoh     7      -1.048   4.730  -4.281  1.00  0.00      wat  h hetatm   24  o   hoh     8      -4.693   5.472  -0.557  1.00  0.00      wat  o hetatm   25  h   hoh     8      -3.881   4.900  -0.521  1.00  0.00      wat  h hetatm   26  h   hoh     8      -4.819   5.805  -1.485  1.00  0.00      wat  h hetatm   27  o   hoh     1       0.289  -5.035   5.663  1.00  0.00      wat  o hetatm   28  h   hoh    10       0.241  -4.604  -5.564  1.00  0.00      wat  h hetatm   29  h   hoh     1      -0.399  -5.750   5.605  1.00  0.00      wat  h hetatm   30  o   hoh    11      -1.741  -5.167   0.877  1.00  0.00      wat  o hetatm   31  h   hoh     0      -2.612  -4.754   0.636  1.00  0.00      wat  h hetatm   32  h   hoh     0      -1.819  -5.599   1.769  1.00  0.00      wat  h 

however, columns 25 , 26 in lines 29 34 (and lines beyond 34 not included here) need edited. represent id number of water molecules in file. so, columns 25 , 26 in lines 29-31 supposed ' 9' instead of ' 1' or '10', , columns 25 , 26 in lines 32-34 supposed '10' instead of '11' or ' 0'. , lines after 34 suffers similar problem , want change contents in columns 25 , 26 '12','13',etc. each group of 3 lines. final result expected this.

hetatm   21  o   hoh     7      -1.609   5.551  -4.296  1.00  0.00      wat  o hetatm   22  h   hoh     7      -1.594   5.971  -3.395  1.00  0.00      wat  h hetatm   23  h   hoh     7      -1.048   4.730  -4.281  1.00  0.00      wat  h hetatm   24  o   hoh     8      -4.693   5.472  -0.557  1.00  0.00      wat  o hetatm   25  h   hoh     8      -3.881   4.900  -0.521  1.00  0.00      wat  h hetatm   26  h   hoh     8      -4.819   5.805  -1.485  1.00  0.00      wat  h hetatm   27  o   hoh     9       0.289  -5.035   5.663  1.00  0.00      wat  o hetatm   28  h   hoh     9       0.241  -4.604  -5.564  1.00  0.00      wat  h hetatm   29  h   hoh     9      -0.399  -5.750   5.605  1.00  0.00      wat  h hetatm   30  o   hoh    10      -1.741  -5.167   0.877  1.00  0.00      wat  o hetatm   31  h   hoh    10      -2.612  -4.754   0.636  1.00  0.00      wat  h hetatm   32  h   hoh    10      -1.819  -5.599   1.769  1.00  0.00      wat  h 

so far couldn't come nice pattern replace funky numbers 9,10,etc. great if replace these groups of 3 lines in single vim command instead of having group group, there 50-60 groups of these problem. did earlier :26,28s/hoh 1/hoh 8 , not efficient way.

sorry not being clear @ first attempt of question, appreciated. thank you

your question not clear, understand, trying select rectangular block in visual mode might you. use ctrl-v in os x or linux or ctrl-q in windows (in normal mode).


Comments