Bash: minimal .vimrc settings for python and yaml editing

If you are using vim on a constrained system (container or production system), you may not have the ability to setup vim plugin managers and plugins to mimic a full development environment.

However, with a few basic settings in ‘~/.vimrc’, you can get a reasonable rendering that will assist in troubleshooting.

" find list using: ls -l /usr/share/vim/vim*/colors
colorscheme torte
set paste
set ruler

" basic settings for yaml and python files
autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab number autoindent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab autoindent

" folding can help troubleshoot indentation syntax
set foldenable
set foldlevelstart=20
set foldmethod=indent
nnoremap <space> za

If there are already system-wide settings and you just want to override specific settings, you can use ~/.vimrc to source the “$VIMRUNTIME/defaults.vim” and then load values on top like:

echo -en 'source $VIMRUNTIME/defaults.vim\ncolorscheme torte\nset mouse=' | tee ~/.vimrc

make sure $VIMRUNTIME does not get evaluated by the shell when creating the file, this special variable needs to be evaluated by vim.

REFERENCES

arthurkoziel.com, vim for yaml

benjamin-phillip.github.io, vim-plug and NERDTree example

krenger.ch, vim settings for yaml

stackexchange, using VIMRUNTIME for base with specific overrides

thevaluable.dev, VIMRUNTIME evaluated when vim starts

NOTES

Assuming global defaults with user overrride with ~/.vimrc

source $VIMRUNTIME/defaults.vim
colorscheme torte
set mouse=