DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer
  • Reducing Alert Fatigue in the SOC Using Correlation Rules and Detection-as-Code
  • Enterprise Kubernetes Failures: 20 Critical Misconfigurations Guardon Catches Before Outages
  • Distributed Cloud-Based Dynamic Configuration Management

Trending

  • Grounding AI Agents in Governed Data
  • How to Format Articles for DZone
  • What Cloud Engineers Actually Need to Know About AI Infrastructure
  • How Kestra Unifies Enterprise Workflow Orchestration and Agentic AI

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Languages
  4. Vim Settings for Working With YAML [Snippet]

Vim Settings for Working With YAML [Snippet]

Let's take a look at a short tutorial that gives an explanation of the vim settings for working with YAML.

By 
Lorna Mitchell
·
Nov. 07, 18 · Code Snippet
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
19.5K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Having managed to avoid YAML until quite recently, my vim installation wasn't well set up at all for working with it. It needs more config settings than plugins, so I thought I'd write down what I found helpful. I'm using it quite a lot now I'm working with OAS (used to be Swagger) API definitions.

Let's start with the easy bit: I'm using the yaml-vim plugin. This seems to do a decent job of syntax highlighting, really helping to spot mistakes!

I added a bunch of configuration to my .vimrc also:

" add yaml stuffs
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

By setting the foldmethod to indent, I get a fold on an increase in indentation levels, which really helps to just expand the bits I'm working on and generally be able to find my way around a file (Pythonistas may find this setting useful since Python works on a similar indentation basis).

Most of the rest of the configuration is around indentation. Yaml does not allow tabs, and indents are multiples of two spaces, so I've set the expandtab value here and also set tabstop/soft tabstop ( ts and sts), and shiftwidth ( sw) to 2.

Bonus pro tip: Try openapi-spec-validator to check your OAS documents are making sense.

YAML Vim (text editor)

Published at DZone with permission of Lorna Mitchell. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer
  • Reducing Alert Fatigue in the SOC Using Correlation Rules and Detection-as-Code
  • Enterprise Kubernetes Failures: 20 Critical Misconfigurations Guardon Catches Before Outages
  • Distributed Cloud-Based Dynamic Configuration Management

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook