I'm writing more Ansible playbooks and yaml is such a big part of it. Although, I usually write playbooks in VSCode, for the RHCE (Red Hat Certified Engineer) exam, you'll rely on Vim exclusive (or nano, but that's not what I'm referring to).
Here are my .vimrc settings. Although there are other examples of .vimrc out there, this works for me. Here is an explanation of the settings.
Turn syntax highlighting on according to the current value of fileType which in this case is yaml
Setting commands to be automatically executed when reading or writing a file.
Setting vim to recognize yaml filetypes.
Setting the local (not global) options in your current window/buffer.
Auto indent (ai) copies the indent from the current line when starting a new line.
Tabstop is the number of spaces that a tab counts for. ts=2 is 2 spaces in a tab.
Shift width is the number of spaces to use for each step of auto indent (ai).
Prints the line number in front of each line. This really makes it easier to troubleshoot errors.
Expand tab uses the appropriate number of spaces to insert a tab.
Shows the line that the cursor is on with horizontal line
Shows the column that the cursor is in. My favorite setting, tbh.
Sets the title of the terminal window to the name of the file you're currently editing.
