Answer a question

I have around 50 markdown files with frontmatter. Something like this:

---
title: Funny Title
date: 2020-01-09
---

I'd like to edit all of the files such that I have the following:

---
title: Conference Volunteering
dateCreated: 2020-01-09
dateUpdated: 2020-01-09

That's it. I was able to right a macro in Vim to do this for me, but did not find a way to run this on multiple files. Now I'm thinking there must be a way to do this in VS Code.

For example, I can search and replace date with dateCreated in all *.md files. That would get me halfway there, I just can't figure out how to also duplicate this line and replace dateCreated with dateUpdated

Any help appreciated. If you need more details/explanations, please let me know.

Answers

do a regex search with

Search: date: (.*)

Replace: dateCreated: $1\ndateUpdated: $1

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐