Reputation: 3046
I want to change in vim the following text:
test aatest
aaaa test a2test
xxxxx test 4 xctesc
to
test a5test
aaaa test a5test
xxxxx test 4 x5tesc
I want to change the 5th to last character of each line into 5
Is there a command that can change the nth column relative to the last column on multiple lines?
Upvotes: 0
Views: 53
Reputation: 172590
Already mentioned in the comments: For each line, go to the end, move 4 left, replace.
:%normal! $4hr5
With :substitute
: match the 5 last characters, capturing the first and last four separately, then modify in the replacement.
:%substitute/\(.\)\(....\)$/5\2/
Upvotes: 1