user2865237
user2865237

Reputation: 11

VIM Deleting ^B and previous characters

Example

Ë^_I^BTest: 717121 -- V3K AD 1 Chan 1 CALBYPASS relays test

I want to delete the ^B and all character to the beginning of the line.

Upvotes: 1

Views: 513

Answers (1)

Keith Thompson
Keith Thompson

Reputation: 263307

vim fundamentally treats Control-B like any other character; it's just slightly more difficult to enter it (you have to typeCtrl-V Ctrl-B), and it's displayed as ^B rather than as itself (since it's a non-printable character).

In a regular expression, ^ matches the beginning of the line, and .* matches any number of arbitrary characters. So, assuming you're on the line containing the ^B, type:

:s/^.*^B//

where for ^B you need to type Ctrl-V Ctrl-B.

This will change the line from:

Ë^_I^BTest: 717121 -- V3K AD 1 Chan 1 CALBYPASS relays test

to:

Test: 717121 -- V3K AD 1 Chan 1 CALBYPASS relays test

Upvotes: 2

Related Questions