- Upgrading the Firmware on a Tulip
- Learning Code Through the Advent of Code Challenge
- Common Loki Misconfigurations
- Iterating Through a List in Ink
- Debugging Misconfigured Container Networks
- Minimum Viable EC2 in Terraform
- Storylets in Ink
- Interactive Fiction Tooling Overview
- In-Place Resizing for Digitalocean Droplets
- Unity Demonstrates the Importance of FOSS
- Target Labels in Prometheus
- My View of AI is the Same
- Verify DNS Ownership with TXT Records
- Sane Droplet Defaults
- Editing Made Easy with Vim
- Gatsby Gotchas
- Concatinating Default AWS Tags in Terraform
- Easily Updating the Default Github Branch
- Lifetimes in Rust
- Checking for Bad Links
- Maybe TypeScript and React is Bad
- Static Asset Management in React
- Bundler Down Time
- Using React Context for Localization
- JS Implementation of a Sticky Footer
- Custom Aliases
- Trying Out the 7drl Challenge
- Trash Opinions
- Building Your First Program in Rust
- Fixing mongod reports errors related to opening a socket
- Improving Open Source Maintenance
- Technical Interviewing Tips
- Housekeeping Note
- Dynamic Programming Basics
- The Oddity of Naming Conventions in Programming Languages
- An Experiment Using Machine Learning, Part 3
- Debugging with grep
- An Experiment Using Machine Learning, Part 2
- An Experiment Using Machine Learning, Part 1
- The Value of while
- National Day of Civic Hacking
- OpenAI and the Future of Humanity
- Creating a Whiteboard App in Django
- Creating Meaningful, Organized Information
- Towards A Critique of Social Media Feeds
- Setting up Routes in Django
- Developing a Messaging Component for Code for SF
- Dream Stream 2.0
- Keyed Collections in Javascript: Maps and Sets
- Blog Soft Relaunch
- Scraping with Puppeteer
- Looking Ahead to Dream Stream 2.0
- Solving West of Loathing's Soupstock Lode Puzzle
- Installing Ubuntu
- Interview with David Jickling Evaluation
- Compare Text Evaluation
- Dream Stream Evaluation
Editing Made Easy with Vim
Thanks to the shift to DevOps practices in deploying code, people are spending a lot more time these days editing yaml files that are used to configure their CI/CD pipeline. Most people I know don’t love yaml– for new users there are lots of weird ways to shoot yourself in the foot when trying to include string data, and getting the correct indentation/spacing can sometimes be tricky. However it has several useful features that are unavailable in a more rigid data format like JSON such as being able to leave comments, or assign variables, and this makes it a more useful format for a lot of configuration tasks. Regardless of how you feel about yaml, it will probably be with us for some time as alternatives like toml tend to be fairly similiar in their approach.
An editor like Vim, or VSCode with some Vim-like features enabled, can make the editing and maintenance of yaml configuration files much easier. Imagine you have a large yaml file, and some feature of a collection is being removed. You might have some config file that looks like this:
- video: path/to/file.mp4
image: path/to/file.webp
text: lorem ipsum...
You could have thousands of entries like this. But suddenly the spec has changed, your not using video anymore, you can get rid of that. Great, you definitely want to do that because your pipeline is using this config file to determine what static assets it needs to buindle together for the build, so removing all those video files will cut down your build time, making all your developers happy.
So you use vim’s sed features to delete the lines that begin with - video:
, and you also remove any lines that are just white space. You also do a search and replace for images, which are now the first part of these collections with %s/image:/- image/g
. Great, but now there is one problem. The indentation for image is off, so your config file won’t work. Manually fixing that would suck. Luckily Vim also has the global command so you can find patterns, and execute globally on that line.
:g/- image:/<
Vim looks for every line with the - image:
pattern, and executes the <
command, which sets the indentation back one as specified by your vimrc file. You now have a valid yaml configuration file that meets the new specifications, and get to move on with your day. Yay!