We will configure vim for easy editing of YAML files. It helps in avoiding indentation space issues for YAML
Create or update .vimrc file in your home directory
ubuntu@lb:~$ touch ~/.vimrc
Add below code to the .vimrc file
ubuntu@lb:~$ cat ~/.vimrc
syntax on
filetype plugin indent on
"Get the 2-space YAML as the default when hit carriage return after the colon
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set is hlsearch ai ic scs
nnoremap <esc><esc> :nohls<cr>
Break down of above entries
autocmd — Executes commands automatically when reading or writing a file
FileType — Vim can detect the type of file that is edited based on input text
setlocal — When you use :setlocal a global option, the new value is local.
ts — Set global tab spacing.
sts — Number of spaces that a counts for while performing editing operations
sw — shiftwidth (the number of spaces to use when indenting or — -de-indenting — -a line)
expandtab or et — (spaces instead of tabs). The expandtab property will ensure that when you hit tab it will actually use spaces.