KubernetesLinux
My .vimrc for Kubernetes YAML (2 spaces and a whitespace alarm)
The other half of my container setup is the .vimrc. Two spaces is the standard for Kubernetes YAML (and Git diffs and colleagues will point out the rest), so this config forces 2 spaces everywhere and shows trailing whitespace as a red error so I catch it before committing.
As /root/.vimrc:
" Ensure Vim uses filetype plugins
filetype plugin on
" Enable indentation
filetype indent on
" Set the default indentation to 2 spaces for all files
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
" Highlight trailing whitespace in all files
autocmd BufRead,BufNewFile * match Error /\s\+$/
" Enable auto-indentation
set autoindent
" Turn on syntax highlighting
syntax on
" Set backspace so it acts more intuitively
set backspace=indent,eol,startThe important parts:
tabstop/softtabstop/shiftwidth=2+expandtab: everything becomes real spaces, never tabs.match Error /\s\+$/: trailing whitespace glows red.filetype plugin/indent on: YAML gets its own indentation logic automatically.
Same principle as with the bashrc: the file lives in the build context and COPY vimrc /root/.vimrc brings it in, so it survives rebuilds.