Vim removes character from position

How can I remove one character from any position? For example, I have a string hello, remove the third char and get helo. I tried using the following expression, but it doesn't work.

.s/\%3c//g

      

+3


source to share


2 answers


Special atom \%c

- zero-width match; that is, it adds a constraint (on the byte count of the match) without using a character . To do this, add another atom that consumes it, for example. .

for any character match. Then your replacement will work as expected:



.s/\%3c.//g

      

+5


source


In normal mode , also known as command mode but not to be confused with command line mode , you can enter:

0 3 l x

0to go to the beginning of the line.



3 l to move three characters forward.

xto delete the character under the cursor.

0


source







All Articles