ahguobrf
ahguobrf

Reputation: 85

Vim remove character from position

How can I remove one character from some position ? For example, I have string hello, remove third char and get helo. I have tried to use next expression, but it doesn't work.

.s/\%3c//g

Upvotes: 3

Views: 934

Answers (2)

Ortomala Lokni
Ortomala Lokni

Reputation: 62466

In normal mode also known as command mode but not to confuse with command-line mode, you can type:

03lx

0 to go to the start of the line.

3l to move 3 characters forward.

x to remove the character under the cursor.

Upvotes: 0

Ingo Karkat
Ingo Karkat

Reputation: 172520

The \%c special atom is a zero-width match; i.e. it adds a restriction (on the byte count of the match) without consuming the character. To do this, append another atom that consumes it, e.g. . for any character match. Then, your substitution will work as expected:

.s/\%3c.//g

Upvotes: 7

Related Questions