---
title: "Bob Belderbos on X: \"Forget Python for a sec, here's how Vim h..."
description: "!https://twitter.com/bbelderbos/status/1709525676154368055"
date: 2023-10-05
published: true
tags:
  - regex
  - thought
  - vim
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://twitter.com/bbelderbos/status/1709525676154368055" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-image">
      <img src="https://pbs.twimg.com/profile_images/1365563799571431428/wj7Hu5-6_200x200.jpg" alt="Bob Belderbos (@bbelderbos) on X — Forget Python for a sec, here&#39;s how Vim helped me out today ... 💪 📈

Ever felt like you needed a quick string replacement without diving into a script? Here&#39;s a Vim trick I just used ...

I wanted to replace all occurrences of:

name,name@example.com,0,171,,2023-09-21

With:" loading="lazy">
    </div>
    <div class="embed-card-content">
      <div class="embed-card-title">Bob Belderbos (@bbelderbos) on X</div>
      <div class="embed-card-description">Forget Python for a sec, here&#39;s how Vim helped me out today ... 💪 📈

Ever felt like you needed a quick string replacement without diving into a script? Here&#39;s a Vim trick I just used ...

I w...</div>
      <div class="embed-card-meta">X (formerly Twitter) &middot; twitter.com</div>
    </div>
  </a>
</div>


I need to learn regex capture groups better.  This is so dang powerful. I really like the \v that bob uses here, it really does cut down on the terseness of all the special characters.

> I wanted to replace all occurrences of:
>
> name,name@example.com,0,171,,2023-09-21
>
> With:
>
> name,name@example.com
>
> Easy to do with Python, but what about a bit of > regex in Vim?
>
> :%s/\v([^,]+,[^,]+),.*/\1/
