1

^ denote the beginning of the line ,$ denote the end of the line. Suppose that there is a line in my vim:

this is a test line test line.

I want to remove all the characters from the 20 th character in the current line (line number is 1) till the end of line.

1s/20th,$//

How to express the 20th character in line1?

1 Answer 1

3

See :h \%c:

                        */\%c* */\%>c* */\%<c*
\%23c   Matches in a specific column.
\%<23c  Matches before a specific column.
\%>23c  Matches after a specific column.
\%.c    Matches at the cursor column.
\%<.c   Matches before the cursor column.
\%>.c   Matches after the cursor column.

In your case:

:s/\%20c.*//

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.