What will be the best .vimrc settings for working with kubernetes

12/28/2019

In my work I have to copy and paste sample manifest snippet from kubernetes documentation site. After copying many a time I have to correct indent and change some section of the copied content. Many a time challenges comes from the structure of the yaml file, specifically space characters and tab characters. Currently I am using the following setting

set number relativenumber
set tabstop=2
set softtabstop=2
set expandtab
set shiftwidth=2

Is there any more setting that I am missing?

-- Arijit Mazumdar
kubernetes
vim

1 Answer

12/28/2019

A few things.

  1. If you are pasting, make sure you do with paste set. It’s a used as a temporary setting for letting the text be put without changes. You can use pastetoggle for this, and tpope’s unimpaired has useful (relevant) mappings.
  2. Don’t sent filetype-specific things in your vimrc. Just, don’t. See, e.g., this QA, this one, or this one (I have more, just ask). Instead, use a filetype-plugin. If kubernetes are all detected as yaml, you would want to use setlocal &co. inside ~/.vim/after/ftplugin/yaml.vim. If they are not given a filetype, you may need to create a filetype-detection script (Google and the Vim help are quite good resources for this).
  3. It’s recommended not to adjust tabstop, since you can’t control how wide a tab is on every display (you can always control spaces, though ;)).
-- D. Ben Knoble
Source: StackOverflow