diff --git a/clang/tools/clang-format/clang-format.py b/clang/tools/clang-format/clang-format.py index bf84ed0f5cfd..1d27985ea085 100644 --- a/clang/tools/clang-format/clang-format.py +++ b/clang/tools/clang-format/clang-format.py @@ -69,7 +69,7 @@ else: output = json.loads(lines[0]) lines = lines[1:] sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines) - for op in sequence.get_opcodes(): + for op in reversed(sequence.get_opcodes()): if op[0] is not 'equal': vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] vim.command('goto %d' % (output['Cursor'] + 1))