showkey
showkey

Reputation: 348

How to add string into the designated position?

Line:
I am here.
I want to add string ok from the 12th column in the Line.

The vim script :s/$/ ok works fine. If the Line is Iamhere.,the vim script change into :s/$/ ok. How to write a smart command to do the job?

Upvotes: 2

Views: 26

Answers (1)

Matt Gregory
Matt Gregory

Reputation: 8652

\%12c will match the 12th column, so :%s/\%12c/ok/ will insert "ok" in the 12th column in every line of the file.

See :help pattern-overview

Upvotes: 1

Related Questions