Hello that works if I execute the command in the normal mode in VIM. Now my next question is:
How can I use the %s command from a VIM script in order to modify a given line of a file? Thank you Tim Chase-2 wrote: > >> I have a vim script which I want to use to search & replace a >> part out of a given line. The fields in the line are based on >> field length and the field I want to change starts at position >> 33 and ends after 4 charachter. >> >> A regex search is not appropriet, as the string I am looking >> for may occur in another field in the same line but shoult not >> be changed here. I already tried substitute() and had a look >> to the normal command :s with a subset, but none of them >> worked for me. > > > I think you may be looking for the zero-width atoms in the "\%#c" > family, so you might search for something like > > :%s/\%33cABCD/FGHI/ > > (there may be an off-by-one error here, so you might have to > adjust that 33 to be 32 or 34 to land on your proper column). > This would replace any "ABCD" starting at column 33 with "FGHI" > > There are a family of these: > > :help /\%c > :help /\%v > :help /\%l > > They're all right next to each other in the help and allow you to > do exactly what you describe, searching for a given item at a > given column offset (there are subtle differences between the %c > and %v varieties). > > Hope this helps, > > -tim > > > > > > -- View this message in context: http://www.nabble.com/Search---Replace-in-VIM-Script-tf3473037.html#a9696683 Sent from the Vim - General mailing list archive at Nabble.com.
