Substitute text



Do you have an idea how I best can substitute text?

The task is to replace each occurrence in a text area, maybe replace
the word "len" by "size" in a function.

I get the ranges from ninsuggest process, the start positions, the word
to replace and the replacement. I have already this code, which marks
that ranges:

buffer.getIterAtLineIndex320(startIter, ln, cn)
endIter = startIter
discard endIter.forwardChars(fix.len) # fix is the word to substitute
buffer.applyTag(tag, startIter, endIter)

That was very easy, because it is similar to my other code.

I know that there are delete() and insert() functions available, but I
have still to learn how to use them for this case.

May I use the mark? Or better place startIter and endIter and use that
position.

Indeed this is still the easy case, all replacements in the current
open file. Nimsuggest may give me positions for the whole project, so
that I can do replacements in files on disk. I am not sure if I will
support that at all, it is a bit dangerous.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]